Module: RedisHash::Mutations

Extended by:
ActiveSupport::Concern
Included in:
Base
Defined in:
lib/redis_hash/concerns/mutations.rb

Instance Method Summary collapse

Instance Method Details

#compact!Object



8
9
10
# File 'lib/redis_hash/concerns/mutations.rb', line 8

def compact!
  delete_if { |_, value| value.blank? }
end

#invertObject



12
13
14
15
16
# File 'lib/redis_hash/concerns/mutations.rb', line 12

def invert
  inversion = to_h.invert
  clear
  inversion.each { |key, value| self[key] = value }
end

#replace(other_hash) ⇒ Object



18
19
20
# File 'lib/redis_hash/concerns/mutations.rb', line 18

def replace(other_hash)
  clear and merge!(other_hash)
end