lib/spark_api/models/base.rb in spark_api-1.3.3 vs lib/spark_api/models/base.rb in spark_api-1.3.6
- old
+ new
@@ -53,15 +53,16 @@
end
def initialize(attributes={})
@attributes = {}
@errors = []
- load(attributes)
+ load(attributes, { :clean => true })
end
- def load(attributes)
+ def load(attributes, options = {})
attributes.each do |key,val|
+ attribute_will_change!(key) unless options[:clean]
@attributes[key.to_s] = val
end
end
def self.get(options={})
@@ -124,10 +125,11 @@
!@attributes['Id'].nil? && !@attributes['ResourceUri'].nil?
end
protected
- def write_attribute(attribute, value)
+ def write_attribute(attribute, value)
+ attribute = attribute.to_s
unless attributes[attribute] == value
attribute_will_change!(attribute)
attributes[attribute] = value
end
end