Module: SimpleAMS::Options::Concerns::ValueHash
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#value ⇒ Object
(also: #name)
readonly
Returns the value of attribute value.
Instance Method Summary collapse
Instance Attribute Details
#options ⇒ Object
Returns the value of attribute options.
6 7 8 |
# File 'lib/simple_ams/options/concerns/value_hash.rb', line 6 def end |
#value ⇒ Object Also known as: name
Returns the value of attribute value.
6 7 8 |
# File 'lib/simple_ams/options/concerns/value_hash.rb', line 6 def value @value end |
Instance Method Details
#initialize(value, options = {}, resource:, serializer:) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/simple_ams/options/concerns/value_hash.rb', line 8 def initialize(value, = {}, resource:, serializer:) if value.is_a?(Proc) #TODO: maybe we should do duck typing instead? _value = value.call(resource, serializer) if _value.is_a?(Array) && _value.length > 1 @value = _value.first = (_value.last || {}).merge( || {}) else @value = _value = || {} end else @value = value.is_a?(String) ? value.to_sym : value = || {} end end |
#raw ⇒ Object
26 27 28 |
# File 'lib/simple_ams/options/concerns/value_hash.rb', line 26 def raw [value, ] end |