Class: SimplyStored::Couch::HasMany::Property

Inherits:
Object
  • Object
show all
Defined in:
lib/simply_stored/couch/has_many.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of Property.



119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
# File 'lib/simply_stored/couch/has_many.rb', line 119

def initialize(owner_clazz, name, options = {})
  options = {
    :dependent => :nullify,
    :through => nil
  }.update(options)
  @name, @options = name, options
  
  options.assert_valid_keys(:dependent, :through)
  
  if options[:through]
    owner_clazz.class_eval do
      define_has_many_through_getter(name, options[:through])
      define_has_many_count(name, options[:through])
    end
  else
    owner_clazz.class_eval do
      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

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



117
118
119
# File 'lib/simply_stored/couch/has_many.rb', line 117

def name
  @name
end

#optionsObject (readonly)

Returns the value of attribute options.



117
118
119
# File 'lib/simply_stored/couch/has_many.rb', line 117

def options
  @options
end

Instance Method Details

#association?Boolean

Returns:

  • (Boolean)


164
165
166
# File 'lib/simply_stored/couch/has_many.rb', line 164

def association?
  true
end

#build(object, json) ⇒ Object



154
155
# File 'lib/simply_stored/couch/has_many.rb', line 154

def build(object, json)
end

#destroy(object) ⇒ Object



151
152
# File 'lib/simply_stored/couch/has_many.rb', line 151

def destroy(object)
end

#dirty?(object) ⇒ Boolean

Returns:

  • (Boolean)


147
148
149
# File 'lib/simply_stored/couch/has_many.rb', line 147

def dirty?(object)
  false
end

#save(object) ⇒ Object



144
145
# File 'lib/simply_stored/couch/has_many.rb', line 144

def save(object)
end

#serialize(json, object) ⇒ Object



157
158
# File 'lib/simply_stored/couch/has_many.rb', line 157

def serialize(json, object)
end

#supports_dirty?Boolean

Returns:

  • (Boolean)


160
161
162
# File 'lib/simply_stored/couch/has_many.rb', line 160

def supports_dirty?
  false
end