Module: SparkApi::Models::Dirty

Included in:
Base
Defined in:
lib/spark_api/models/dirty.rb

Instance Method Summary collapse

Instance Method Details

#changedObject



9
10
11
# File 'lib/spark_api/models/dirty.rb', line 9

def changed
  changed_attributes.keys
end

#changed?Boolean

Returns:

  • (Boolean)


5
6
7
# File 'lib/spark_api/models/dirty.rb', line 5

def changed?
  changed.any?
end

#changed_attributesObject

hash with changed attributes and their original values



22
23
24
# File 'lib/spark_api/models/dirty.rb', line 22

def changed_attributes
  @changed_attributes ||= {}
end

#changesObject



13
14
15
# File 'lib/spark_api/models/dirty.rb', line 13

def changes
  Hash[changed.map { |attr| [attr, attribute_change(attr)] }]
end

#dirty_attributesObject

hash with changed attributes and their new values



27
28
29
# File 'lib/spark_api/models/dirty.rb', line 27

def dirty_attributes
  changed.inject({}) { |h, k| h[k] = attributes[k.to_s]; h }
end

#previous_changesObject



17
18
19
# File 'lib/spark_api/models/dirty.rb', line 17

def previous_changes
  @previously_changed
end