Class: SimplyStored::Couch::HasMany::Property
- Inherits:
-
AssociationProperty
- Object
- AssociationProperty
- SimplyStored::Couch::HasMany::Property
- Defined in:
- lib/simply_stored/couch/has_many.rb
Instance Attribute Summary
Attributes inherited from AssociationProperty
Instance Method Summary collapse
-
#initialize(owner_clazz, name, options = {}) ⇒ Property
constructor
A new instance of Property.
Methods inherited from AssociationProperty
#association?, #build, #dirty?, #serialize, #supports_dirty?
Constructor Details
#initialize(owner_clazz, name, options = {}) ⇒ Property
Returns a new instance of Property.
134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 |
# File 'lib/simply_stored/couch/has_many.rb', line 134 def initialize(owner_clazz, name, = {}) = { :dependent => :nullify, :through => nil, :class_name => name.to_s.singularize.camelize, :foreign_key => nil }.update() @name, @options = name, .assert_valid_keys(:dependent, :through, :class_name, :foreign_key) if [:through] owner_clazz.class_eval do _define_cache_accessors(name, ) define_has_many_through_getter(name, , [:through]) define_has_many_count(name, , [:through]) end else owner_clazz.class_eval do _define_cache_accessors(name, ) define_has_many_getter(name, ) define_has_many_setter_add(name, ) define_has_many_setter_remove(name, ) define_has_many_setter_remove_all(name, ) define_has_many_count(name, ) end end end |