Class: LedgerSync::Util::ResourceConverter::Type::ResourceConverterType

Inherits:
Type::Value
  • Object
show all
Defined in:
lib/ledger_sync/util/resource_converter/type/resource_converter_type.rb

Direct Known Subclasses

ReferencesManyType, ReferencesOneType

Instance Attribute Summary collapse

Instance Method Summary collapse

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_converterObject (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