Module: Taskrabbit::Association::ClassMethods

Defined in:
lib/taskrabbit/association.rb

Instance Method Summary collapse

Instance Method Details

#has_many(association, klass, options = {}) ⇒ Object

define has many that will proxy the association to the class if the association has been loaded previously, no proxy will be used



14
15
16
17
18
19
20
21
22
# File 'lib/taskrabbit/association.rb', line 14

def has_many(association, klass, options = {})
  class_eval <<-"END"
  def #{association}
    return self[:#{association}] if property_present?(:#{association})
    @#{association} ||= Proxy.new(self, #{klass})
  end
  END
  self::PATHS[klass] = options[:on]
end