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