module VzaarApi::Lib::ActiveObject::Save::InstanceMethods
Public Instance Methods
changed()
click to toggle source
# File lib/vzaar_api/lib/active_object.rb, line 55 def changed changes.keys end
changed?()
click to toggle source
# File lib/vzaar_api/lib/active_object.rb, line 51 def changed? !changes.empty? end
changed_attributes()
click to toggle source
# File lib/vzaar_api/lib/active_object.rb, line 59 def changed_attributes {}.tap do |result| changes.each do |attr, vals| result[attr] = vals[1] end end end
changes()
click to toggle source
# File lib/vzaar_api/lib/active_object.rb, line 67 def changes @changes ||= {} end
has_changed?(attr)
click to toggle source
# File lib/vzaar_api/lib/active_object.rb, line 71 def has_changed?(attr) changed.include? attr.to_sym end
save()
click to toggle source
# File lib/vzaar_api/lib/active_object.rb, line 38 def save if changed? response = Lib::Api.new.patch( resource_url(id, scope_id), changed_attributes ) update_from_attributes response.data saved! end true end
Private Instance Methods
saved!()
click to toggle source
# File lib/vzaar_api/lib/active_object.rb, line 75 def saved! @changes = nil end