module OldApiResource::Attributes::InstanceMethods
Public Instance Methods
attribute?(name)
click to toggle source
# File lib/old_api_resource/attributes.rb, line 140 def attribute?(name) self.class.attribute?(name) end
attributes=(new_attrs)
click to toggle source
set new attributes
# File lib/old_api_resource/attributes.rb, line 107 def attributes=(new_attrs) new_attrs.each_pair do |k,v| self.send("#{k}=",v) end new_attrs end
protected_attribute?(name)
click to toggle source
# File lib/old_api_resource/attributes.rb, line 144 def protected_attribute?(name) self.class.protected_attribute?(name) end
reset_attribute_changes(*attrs)
click to toggle source
# File lib/old_api_resource/attributes.rb, line 131 def reset_attribute_changes(*attrs) attrs = self.class.public_attribute_names if attrs.blank? attrs.each do |attr| self.send("reset_#{attr}!") end set_attributes_as_current(*attrs) end
respond_to?(sym)
click to toggle source
Calls superclass method
# File lib/old_api_resource/attributes.rb, line 148 def respond_to?(sym) if sym =~ /\?$/ return true if self.attribute?($`) elsif sym =~ /=$/ return true if self.class.public_attribute_names.include?($`) else return true if self.attribute?(sym.to_sym) end super end
save_with_dirty_tracking(*args)
click to toggle source
# File lib/old_api_resource/attributes.rb, line 114 def save_with_dirty_tracking(*args) if save_without_dirty_tracking(*args) @previously_changed = self.changes @changed_attributes.clear return true else return false end end
set_attributes_as_current(*attrs)
click to toggle source
# File lib/old_api_resource/attributes.rb, line 124 def set_attributes_as_current(*attrs) @changed_attributes.clear and return if attrs.blank? attrs.each do |attr| @changed_attributes.delete(attr.to_s) end end