Module: LedgerSync::Ledgers::Client::Mixin::ClassMethods

Defined in:
lib/ledger_sync/ledgers/client.rb

Instance Method Summary collapse

Instance Method Details

#base_moduleObject



73
74
75
# File 'lib/ledger_sync/ledgers/client.rb', line 73

def base_module
  config.base_module
end

#configObject



77
78
79
# File 'lib/ledger_sync/ledgers/client.rb', line 77

def config
  @config ||= LedgerSync.ledgers.config_from_class(client_class: self)
end

#ledger_attributes_to_saveObject

These are attributes that must always be saved after the client is called. For example, the library will handle refreshing tokens that will need to be saved back to the application layer for future use.

Raises:

  • (NotImplementedError)


84
85
86
# File 'lib/ledger_sync/ledgers/client.rb', line 84

def ledger_attributes_to_save
  raise NotImplementedError
end

#ledger_resource_type_for(resource_class:) ⇒ Object



88
89
90
# File 'lib/ledger_sync/ledgers/client.rb', line 88

def ledger_resource_type_for(resource_class:)
  ledger_resource_type_overrides[resource_class] || resource_class.resource_type.to_s
end

#ledger_resource_type_overridesObject



92
93
94
# File 'lib/ledger_sync/ledgers/client.rb', line 92

def ledger_resource_type_overrides
  {}
end

#operation_class_for(*args, **keywords) ⇒ Object



96
97
98
# File 'lib/ledger_sync/ledgers/client.rb', line 96

def operation_class_for(*args, **keywords)
  Client.operation_class_for(*args, **keywords)
end

#resource_from_ledger_type(type:, converter: nil) ⇒ Object



100
101
102
103
# File 'lib/ledger_sync/ledgers/client.rb', line 100

def resource_from_ledger_type(type:, converter: nil)
  converter ||= proc { |n| n.underscore }
  ledger_resource_type_overrides.invert[converter.call(type).to_sym] || resources[converter.call(type).to_sym]
end

#resourcesObject



105
106
107
# File 'lib/ledger_sync/ledgers/client.rb', line 105

def resources
  @resources ||= {}
end

#root_keyObject



109
110
111
# File 'lib/ledger_sync/ledgers/client.rb', line 109

def root_key
  @root_key ||= config.root_key
end

#searcher_class_for(resource_type:) ⇒ Object



117
118
119
# File 'lib/ledger_sync/ledgers/client.rb', line 117

def searcher_class_for(resource_type:)
  base_module.const_get(LedgerSync::Util::StringHelpers.camelcase(resource_type.to_s))::Searcher
end

#searcher_for(resource_type:, client:, query: '') ⇒ Object



113
114
115
# File 'lib/ledger_sync/ledgers/client.rb', line 113

def searcher_for(resource_type:, client:, query: '')
  searcher_class_for(resource_type: resource_type).new(client: client, query: query)
end

#url_for(resource: nil) ⇒ Object



121
# File 'lib/ledger_sync/ledgers/client.rb', line 121

def url_for(resource: nil); end