Class: EacRubyUtils::Immutable::HashAccessor

Inherits:
BaseAccessor show all
Defined in:
lib/eac_ruby_utils/immutable/hash_accessor.rb

Instance Method Summary collapse

Methods inherited from BaseAccessor

#duplicate_object

Instance Method Details

#apply(klass) ⇒ Object


9
10
11
12
# File 'lib/eac_ruby_utils/immutable/hash_accessor.rb', line 9

def apply(klass)
  apply_get(klass)
  apply_set(klass)
end

#immutable_value_get(object) ⇒ Object


14
15
16
# File 'lib/eac_ruby_utils/immutable/hash_accessor.rb', line 14

def immutable_value_get(object)
  super || {}
end

#immutable_value_set(object, key, value) ⇒ Object


18
19
20
21
22
# File 'lib/eac_ruby_utils/immutable/hash_accessor.rb', line 18

def immutable_value_set(object, key, value)
  duplicate_object(object) do |old_value|
    (old_value || {}).merge(key => value)
  end
end