Class: LedgerSync::Util::ResourceConverter::Type::ResourceConverterType
- Inherits:
-
Type::Value
- Object
- ActiveModel::Type::Value
- Type::Value
- LedgerSync::Util::ResourceConverter::Type::ResourceConverterType
- Defined in:
- lib/ledger_sync/util/resource_converter/type/resource_converter_type.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#resource_converter ⇒ Object
readonly
Returns the value of attribute resource_converter.
Instance Method Summary collapse
- #cast_value(args = {}) ⇒ Object
-
#initialize(args = {}) ⇒ ResourceConverterType
constructor
A new instance of ResourceConverterType.
Methods included from Type::ValueMixin
#assert_valid, #cast, included, #valid?
Constructor Details
#initialize(args = {}) ⇒ ResourceConverterType
Returns a new instance of ResourceConverterType.
10 11 12 13 14 |
# File 'lib/ledger_sync/util/resource_converter/type/resource_converter_type.rb', line 10 def initialize(args = {}) @resource_converter = args.fetch(:resource_converter) super() end |
Instance Attribute Details
#resource_converter ⇒ Object (readonly)
Returns the value of attribute resource_converter.
8 9 10 |
# File 'lib/ledger_sync/util/resource_converter/type/resource_converter_type.rb', line 8 def resource_converter @resource_converter end |
Instance Method Details
#cast_value(args = {}) ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'lib/ledger_sync/util/resource_converter/type/resource_converter_type.rb', line 16 def cast_value(args = {}) destination = args.fetch(:destination) source = args.fetch(:value) return if source.nil? resource_converter.new.convert(destination: destination, source: source) end |