Class: EacRubyUtils::Immutable::BaseAccessor

Inherits:
Object
  • Object
show all
Defined in:
lib/eac_ruby_utils/immutable/base_accessor.rb

Direct Known Subclasses

ArrayAccessor, CommonAccessor, HashAccessor

Instance Method Summary collapse

Instance Method Details

#duplicate_object(object) ⇒ Object


10
11
12
13
14
15
16
# File 'lib/eac_ruby_utils/immutable/base_accessor.rb', line 10

def duplicate_object(object)
  accessor_new_value = yield(immutable_value_get(object))
  new_values = object.send(:immutable_values_get).merge(name => accessor_new_value)
  r = object.class.new(*object.immutable_constructor_args)
  r.send(:immutable_values_set, new_values)
  r
end

#immutable_value_get(object) ⇒ Object


18
19
20
# File 'lib/eac_ruby_utils/immutable/base_accessor.rb', line 18

def immutable_value_get(object)
  object.send(:immutable_values_get)[name]
end