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

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

Instance Method Summary collapse

Instance Method Details

#base_moduleObject



63
64
65
# File 'lib/ledger_sync/ledgers/client.rb', line 63

def base_module
  config.base_module
end

#configObject



67
68
69
# File 'lib/ledger_sync/ledgers/client.rb', line 67

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)


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

def ledger_attributes_to_save
  raise NotImplementedError
end

#ledger_resource_type_for(resource_class:) ⇒ Object



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

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

#ledger_resource_type_overridesObject



82
83
84
# File 'lib/ledger_sync/ledgers/client.rb', line 82

def ledger_resource_type_overrides
  {}
end

#operation_class_for(*args) ⇒ Object



86
87
88
# File 'lib/ledger_sync/ledgers/client.rb', line 86

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

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



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

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



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

def resources
  @resources ||= {}
end

#root_keyObject



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

def root_key
  @root_key ||= config.root_key
end

#searcher_class_for(resource_type:) ⇒ Object



107
108
109
# File 'lib/ledger_sync/ledgers/client.rb', line 107

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



103
104
105
# File 'lib/ledger_sync/ledgers/client.rb', line 103

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

#url_for(resource: nil) ⇒ Object



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

def url_for(resource: nil); end