Class: SimplyCouch::Model::HasManyEmbedded::Property

Inherits:
AssociationProperty show all
Defined in:
lib/simply_couch/model/has_many_embedded.rb

Instance Attribute Summary

Attributes inherited from AssociationProperty

#name, #options

Instance Method Summary collapse

Methods inherited from AssociationProperty

#association?, #build, #dirty?, #serialize, #supports_dirty?

Constructor Details

#initialize(owner_clazz, name, options = {}) ⇒ Property

Returns a new instance of Property.



160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
# File 'lib/simply_couch/model/has_many_embedded.rb', line 160

def initialize(owner_clazz, name, options = {})
  options = {
    :dependent => :nullify,
    :through => nil,
    :class_name => name.to_s.singularize.camelize,
    :foreign_key => nil
  }.update(options)
  @name, @options = name, options
  
  options.assert_valid_keys(:dependent, :through, :class_name, :foreign_key)
  
  owner_clazz.class_eval do
    property name, :type => Array
    _define_cache_accessors(name, options)
    define_has_many_embedded_getter(name, options)
    define_has_many_embedded_setter(name, options)
    define_has_many_embedded_setter_add(name, options)
    define_has_many_embedded_setter_remove(name, options)
    define_has_many_embedded_setter_remove_all(name, options)
    define_reset_index_values(name, options)
    define_has_many_embedded_count(name, options)
  end
end