Class: StaticModel::Associations::HasManyAssociation
- Inherits:
-
Association
- Object
- Association
- StaticModel::Associations::HasManyAssociation
- Defined in:
- lib/static_model/associations.rb
Instance Attribute Summary
Attributes inherited from Association
#foreign_key, #klass, #name, #options
Instance Method Summary collapse
Methods inherited from Association
#initialize, #reflection_klass
Constructor Details
This class inherits a constructor from StaticModel::Associations::Association
Instance Method Details
#define_association_methods ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/static_model/associations.rb', line 53 def define_association_methods if reflection_klass.respond_to?(:scoped) klass.module_eval <<-EOT def #{name} #{reflection_klass}.scoped(:conditions => {:#{foreign_key} => id}) end EOT else klass.module_eval <<-EOT def #{name} #{reflection_klass}.send(:find_all_by_#{foreign_key}, id) end EOT end end |