Harbor Documentation

Harbor::AccessorInjector

A simple module to facilitate accessor based injection. This is used by Harbor::Plugin to allow you to easily construct plugins from hashes, i.e.:

  <%= plugin("user/tabs", :user => @user)

It can of course be used for anything, however:

  class Dog
    include Harbor::AccessorInjector
    attr_accessor :owner
  end

  dog = Dog.new.inject(:owner => "Tom")
  dog.owner # => "Tom"

Methods

Public Instance Methods

inject(options = {})

      # File lib/harbor/accessor_injector.rb, line 20
20:     def inject(options = {})
21:       options.each do |key, value|
22:         setter = "#{key}="
23:         send(setter, value) if respond_to?(setter)
24:       end
25: 
26:       self
27:     end