Method: Panda::Associations::ClassMethods#has_many
- Defined in:
- lib/panda/modules/associations.rb
#has_many(relation_name) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/panda/modules/associations.rb', line 25 def has_many(relation_name) # for example creates : @encodings ||= EncodingScope.new(self) define_method relation_name do model_name = "#{relation_name.to_s[0..-2].capitalize}" if instance_var = instance_variable_get("@#{relation_name}") instance_var else @associations ||= [] @associations << relation_name instance_variable_set("@#{relation_name}", Panda::const_get("#{model_name}Scope").new(self)) end end end |