Class: LedgerSync::Serialization::Type::MappingType
- Inherits:
-
Type::Value
- Object
- ActiveModel::Type::Value
- Type::Value
- LedgerSync::Serialization::Type::MappingType
- Defined in:
- lib/ledger_sync/serialization/type/mapping_type.rb
Instance Attribute Summary collapse
-
#hash ⇒ Object
readonly
Returns the value of attribute hash.
Instance Method Summary collapse
- #cast_value(args = {}) ⇒ Object
-
#initialize(args = {}) ⇒ MappingType
constructor
A new instance of MappingType.
Methods included from Type::ValueMixin
#assert_valid, #cast, included, #valid?
Constructor Details
#initialize(args = {}) ⇒ MappingType
Returns a new instance of MappingType.
9 10 11 12 13 |
# File 'lib/ledger_sync/serialization/type/mapping_type.rb', line 9 def initialize(args = {}) @hash = args.fetch(:hash) super() end |
Instance Attribute Details
#hash ⇒ Object (readonly)
Returns the value of attribute hash.
7 8 9 |
# File 'lib/ledger_sync/serialization/type/mapping_type.rb', line 7 def hash @hash end |
Instance Method Details
#cast_value(args = {}) ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/ledger_sync/serialization/type/mapping_type.rb', line 15 def cast_value(args = {}) value = args.fetch(:value) return if value.nil? hash.fetch(value) end |