Class: SimplyStored::Couch::HasOne::Property

Inherits:
AssociationProperty show all
Defined in:
lib/simply_stored/couch/has_one.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.



56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/simply_stored/couch/has_one.rb', line 56

def initialize(owner_clazz, name, options = {})
  options = {
    :dependent => :nullify,
    :class_name => name.to_s.singularize.camelize,
    :foreign_key => nil
  }.update(options)
  @name, @options = name, options
  
  options.assert_valid_keys(:dependent, :class_name, :foreign_key)
  
  owner_clazz.class_eval do
    define_has_one_getter(name, options)
    define_has_one_setter(name, options)
  end
end