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

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

Instance Method Summary collapse

Instance Method Details

#base_moduleObject



69
70
71
# File 'lib/ledger_sync/ledgers/client.rb', line 69

def base_module
  config.base_module
end

#configObject



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

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)


80
81
82
# File 'lib/ledger_sync/ledgers/client.rb', line 80

def ledger_attributes_to_save
  raise NotImplementedError
end

#ledger_resource_type_for(resource_class:) ⇒ Object



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

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

#ledger_resource_type_overridesObject



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

def ledger_resource_type_overrides
  {}
end

#operation_class_for(*args) ⇒ Object



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

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

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



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

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



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

def resources
  @resources ||= {}
end

#root_keyObject



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

def root_key
  @root_key ||= config.root_key
end

#searcher_class_for(resource_type:) ⇒ Object



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

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

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



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

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

#url_for(resource: nil) ⇒ Object



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

def url_for(resource: nil); end