Class: EacRubyUtils::ActsAsImmutable::HashAccessor
Constant Summary
Constants inherited
from BaseAccessor
BaseAccessor::FILTER_GET_METHOD_NAME_FORMAT, BaseAccessor::FILTER_SET_METHOD_NAME_FORMAT
Instance Method Summary
collapse
#duplicate_object, #immutable_value_get_filtered, #immutable_value_get_filtered_method_name, #immutable_value_set_filtered, #immutable_value_set_filtered_method_name
Instance Method Details
#apply(klass) ⇒ Object
9
10
11
12
|
# File 'lib/eac_ruby_utils/acts_as_immutable/hash_accessor.rb', line 9
def apply(klass)
apply_plural(klass)
apply_singular(klass)
end
|
#immutable_value_get(object) ⇒ Object
14
15
16
|
# File 'lib/eac_ruby_utils/acts_as_immutable/hash_accessor.rb', line 14
def immutable_value_get(object)
super || {}
end
|
#immutable_value_get_single(object, key) ⇒ Object
18
19
20
|
# File 'lib/eac_ruby_utils/acts_as_immutable/hash_accessor.rb', line 18
def immutable_value_get_single(object, key)
immutable_value_get(object)[key]
end
|
#immutable_value_set(object, new_hash) ⇒ Object
22
23
24
|
# File 'lib/eac_ruby_utils/acts_as_immutable/hash_accessor.rb', line 22
def immutable_value_set(object, new_hash)
duplicate_object(object) { |_old_value| new_hash }
end
|
#immutable_value_set_single(object, key, value) ⇒ Object
26
27
28
|
# File 'lib/eac_ruby_utils/acts_as_immutable/hash_accessor.rb', line 26
def immutable_value_set_single(object, key, value)
immutable_value_set(object, immutable_value_get(object).merge(key => value))
end
|