Class: LedgerSync::Util::ResourcesBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/ledger_sync/util/resources_builder.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) ⇒ ResourcesBuilder

Returns a new instance of ResourcesBuilder.



13
14
15
16
17
18
19
20
21
# File 'lib/ledger_sync/util/resources_builder.rb', line 13

def initialize(args = {})
  @all_resources                  = {}
  @ledger                         = args.fetch(:ledger)
  @cast                           = args.fetch(:cast, true)
  @data                           = Util::HashHelpers.deep_symbolize_keys(args.fetch(:data))
  @ignore_unrecognized_attributes = args.fetch(:ignore_unrecognized_attributes, false)
  @root_resource_external_id      = args.fetch(:root_resource_external_id)
  @root_resource_type             = args.fetch(:root_resource_type)
end

Instance Attribute Details

#castObject (readonly)

Returns the value of attribute cast.



6
7
8
# File 'lib/ledger_sync/util/resources_builder.rb', line 6

def cast
  @cast
end

#dataObject (readonly)

Returns the value of attribute data.



6
7
8
# File 'lib/ledger_sync/util/resources_builder.rb', line 6

def data
  @data
end

#ignore_unrecognized_attributesObject (readonly)

Returns the value of attribute ignore_unrecognized_attributes.



6
7
8
# File 'lib/ledger_sync/util/resources_builder.rb', line 6

def ignore_unrecognized_attributes
  @ignore_unrecognized_attributes
end

#ledgerObject (readonly)

Returns the value of attribute ledger.



6
7
8
# File 'lib/ledger_sync/util/resources_builder.rb', line 6

def ledger
  @ledger
end

#root_resource_external_idObject (readonly)

Returns the value of attribute root_resource_external_id.



6
7
8
# File 'lib/ledger_sync/util/resources_builder.rb', line 6

def root_resource_external_id
  @root_resource_external_id
end

#root_resource_typeObject (readonly)

Returns the value of attribute root_resource_type.



6
7
8
# File 'lib/ledger_sync/util/resources_builder.rb', line 6

def root_resource_type
  @root_resource_type
end

Instance Method Details

#resourceObject



23
24
25
26
27
28
# File 'lib/ledger_sync/util/resources_builder.rb', line 23

def resource
  @resource ||= build_resource(
    external_id: root_resource_external_id,
    type: root_resource_type
  )
end

#resourcesObject



30
31
32
33
34
35
# File 'lib/ledger_sync/util/resources_builder.rb', line 30

def resources
  @resources ||= begin
    resource
    @all_resources.values
  end
end