module Quandl::Cassinatra::Base::Attributes
Public Instance Methods
imprint(record)
click to toggle source
# File lib/quandl/cassinatra/base/attributes.rb, line 18 def imprint(record) # ensure matching classes raise(ArgumentError, "record must be kind_of?(#{self.class})") unless record.kind_of?( self.class ) # copy variables copy_instance_variables(record) end
inspect()
click to toggle source
# File lib/quandl/cassinatra/base/attributes.rb, line 14 def inspect "#{self.class.name} " + attributes.inspect end
Protected Instance Methods
copy_instance_variables(record)
click to toggle source
# File lib/quandl/cassinatra/base/attributes.rb, line 27 def copy_instance_variables(record) # copy attributes if record was found @attributes = record.attributes if record.exists? # copy metadata and errors [:metadata, :response_errors].each do |ivar| self.instance_variable_set("@#{ivar}", record.instance_variable_get("@#{ivar}") ) end self end
read_attribute(attribute)
click to toggle source
# File lib/quandl/cassinatra/base/attributes.rb, line 46 def read_attribute(attribute) @attributes[:"#{attribute}"] end
write_attribute(attribute, value)
click to toggle source
# File lib/quandl/cassinatra/base/attributes.rb, line 41 def write_attribute(attribute, value) self.send(:"#{attribute}_will_change!") if @attributes[:"#{attribute}"] != value @attributes[:"#{attribute}"] = value end
write_attributes(hash)
click to toggle source
# File lib/quandl/cassinatra/base/attributes.rb, line 37 def write_attributes(hash) @attributes = hash end