Module: ActiveModel::Dirty
- Defined in:
- lib/composite_primary_keys/dirty.rb
Instance Method Summary collapse
- #can_change_primary_key? ⇒ Boolean
- #primary_key_changed? ⇒ Boolean
- #primary_key_was ⇒ Object (also: #ids_hash_was)
Instance Method Details
#can_change_primary_key? ⇒ Boolean
3 4 5 |
# File 'lib/composite_primary_keys/dirty.rb', line 3 def can_change_primary_key? true end |
#primary_key_changed? ⇒ Boolean
7 8 9 |
# File 'lib/composite_primary_keys/dirty.rb', line 7 def primary_key_changed? !!changed.detect { |key| ids_hash.keys.include?(key.to_s) } end |
#primary_key_was ⇒ Object Also known as: ids_hash_was
11 12 13 14 15 16 |
# File 'lib/composite_primary_keys/dirty.rb', line 11 def primary_key_was ids_hash.keys.inject(Hash.new) do |result, attribute_name| result[attribute_name] = attribute_was(attribute_name.to_s) result end end |