Module: CouchPotato::Persistence::Properties::ClassMethods
- Defined in:
- lib/couch_potato/persistence/properties.rb
Instance Method Summary collapse
- #belongs_to(name) ⇒ Object
- #json_create(json) ⇒ Object
- #property(name, options = {}) ⇒ Object
- #property_names ⇒ Object
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, = {}) clazz = .delete(:class) properties << (clazz || SimpleProperty).new(self, name, ) end |
#property_names ⇒ Object
18 19 20 |
# File 'lib/couch_potato/persistence/properties.rb', line 18 def property_names properties.map(&:name) end |