Module: LooseChange::AttributeClassMethods

Included in:
Base
Defined in:
lib/loose_change/attributes.rb

Instance Method Summary collapse

Instance Method Details

#attributesObject

Returns a hash of property names and current values.



43
44
45
# File 'lib/loose_change/attributes.rb', line 43

def attributes
  (self.class.properties || []).inject({}) {|acc, key| acc[key] = send(key); acc}
end

#update_attribute(name, value) ⇒ Object

Change the value of a property and save the result to CouchDB.



48
49
50
51
# File 'lib/loose_change/attributes.rb', line 48

def update_attribute(name, value)
  send("#{name}=", value)
  save
end

#update_attributes(args = {}) ⇒ Object

Change multiple properties at once with a hash of property names and values, then save the result to CouchDB.



55
56
57
58
59
60
# File 'lib/loose_change/attributes.rb', line 55

def update_attributes(args = {})
  args.each do |name, value|
    send("#{name}=", value)
  end
  save
end