class ActiveRedis::DirtyObjects::Hash

Attributes

original[RW]

Public Class Methods

[](*args) click to toggle source
Calls superclass method
# File lib/active_redis/dirty_objects/hash.rb, line 4
def self.[](*args)
  hash = super
  hash.original = hash.dup
  hash
end

Public Instance Methods

changes() click to toggle source
# File lib/active_redis/dirty_objects/hash.rb, line 16
def changes
  {additions: updated_keys, drops: dropped_keys, hash: self}
end
clean!() click to toggle source
# File lib/active_redis/dirty_objects/hash.rb, line 24
def clean!
  @original = dup
end
dirty?() click to toggle source
# File lib/active_redis/dirty_objects/hash.rb, line 12
def dirty?
  @original != self
end
dropped_keys() click to toggle source
# File lib/active_redis/dirty_objects/hash.rb, line 20
def dropped_keys
  @original.keys - self.keys
end
updated_keys() click to toggle source
# File lib/active_redis/dirty_objects/hash.rb, line 28
def updated_keys
  self.keys.select do |key|
    @original[key] != self[key]
  end
end