Module: CouchPotato::Persistence::Properties::ClassMethods

Defined in:
lib/couch_potato/persistence/properties.rb

Instance Method Summary collapse

Instance Method Details

#belongs_to(name) ⇒ Object



35
36
37
# File 'lib/couch_potato/persistence/properties.rb', line 35

def belongs_to(name)
  property name, :class => BelongsToProperty
end

#json_create(json) ⇒ Object



22
23
24
25
26
27
28
# File 'lib/couch_potato/persistence/properties.rb', line 22

def json_create(json)
  instance = super
  instance.attributes.each do |name, value|
    instance.instance_variable_set("@#{name}_was", value)
  end
  instance
end

#property(name, options = {}) ⇒ Object



30
31
32
33
# File 'lib/couch_potato/persistence/properties.rb', line 30

def property(name, options = {})
  clazz = options.delete(:class)
  properties << (clazz || SimpleProperty).new(self, name, options)
end

#property_namesObject



18
19
20
# File 'lib/couch_potato/persistence/properties.rb', line 18

def property_names
  properties.map(&:name)
end