Class: EacRubyUtils::ActsAsImmutable::ArrayAccessor

Inherits:
EnumerableAccessor show all
Defined in:
lib/eac_ruby_utils/acts_as_immutable/array_accessor.rb

Constant Summary collapse

INITIAL_VALUE =
[].freeze

Constants inherited from BaseAccessor

BaseAccessor::FILTER_GET_METHOD_NAME_FORMAT, BaseAccessor::FILTER_SET_METHOD_NAME_FORMAT

Instance Method Summary collapse

Methods inherited from EnumerableAccessor

#apply, #apply_plural, #apply_singular, #immutable_value_get, #immutable_value_push, #immutable_value_set

Methods inherited from BaseAccessor

#duplicate_object, #immutable_value_get, #immutable_value_get_filtered, #immutable_value_get_filtered_method_name, #immutable_value_set_filtered, #immutable_value_set_filtered_method_name

Instance Method Details

#immutable_value_set_assert(value) ⇒ Array

Parameters:

Returns:

  • (Array)


12
13
14
15
16
17
# File 'lib/eac_ruby_utils/acts_as_immutable/array_accessor.rb', line 12

def immutable_value_set_assert(value)
  return value if value.is_a?(::Array)
  return value.to_a if value.respond_to?(:to_a)

  Array(value)
end

#initial_valueArray

Returns A empty array.

Returns:

  • (Array)

    A empty array.



20
21
22
# File 'lib/eac_ruby_utils/acts_as_immutable/array_accessor.rb', line 20

def initial_value
  INITIAL_VALUE
end