class ITGlue::Asset::Attributes
Public Class Methods
new(*args)
click to toggle source
Calls superclass method
# File lib/itglue/asset/base/attributes.rb, line 4 def initialize(*args) @changed_attribute_keys = [] super end
Public Instance Methods
assign_attribute(key, value)
click to toggle source
# File lib/itglue/asset/base/attributes.rb, line 9 def assign_attribute(key, value) @changed_attribute_keys << key.to_sym self[key] = value end
attributes_hash()
click to toggle source
# File lib/itglue/asset/base/attributes.rb, line 23 def attributes_hash self.to_h end
changes()
click to toggle source
# File lib/itglue/asset/base/attributes.rb, line 36 def changes attributes_hash = self.attributes_hash @changed_attribute_keys.each_with_object({}) do |key, changes| changes[key] = attributes_hash[key] end end
inspect_field(field)
click to toggle source
# File lib/itglue/asset/base/attributes.rb, line 27 def inspect_field(field) value = self[field] if value.is_a?(String) value.length > 100 ? "\"#{value[0..100]}...\"" : "\"#{value}\"" else value.inspect end end
keys()
click to toggle source
# File lib/itglue/asset/base/attributes.rb, line 19 def keys self.to_h.keys end
remove_attribute(key)
click to toggle source
# File lib/itglue/asset/base/attributes.rb, line 14 def remove_attribute(key) @changed_attribute_keys.delete(key) self.delete_field(key) end