Module: LedgerSync::Ledgers::Client::Mixin::ClassMethods
- Defined in:
- lib/ledger_sync/ledgers/client.rb
Instance Method Summary collapse
- #base_module ⇒ Object
- #config ⇒ Object
-
#ledger_attributes_to_save ⇒ Object
These are attributes that must always be saved after the client is called.
- #ledger_resource_type_for(resource_class:) ⇒ Object
- #ledger_resource_type_overrides ⇒ Object
- #operation_class_for(*args, **keywords) ⇒ Object
- #resource_from_ledger_type(type:, converter: nil) ⇒ Object
- #resources ⇒ Object
- #root_key ⇒ Object
- #searcher_class_for(resource_type:) ⇒ Object
- #searcher_for(resource_type:, client:, query: '') ⇒ Object
- #url_for(resource: nil) ⇒ Object
Instance Method Details
#base_module ⇒ Object
73 74 75 |
# File 'lib/ledger_sync/ledgers/client.rb', line 73 def base_module config.base_module end |
#config ⇒ Object
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_save ⇒ Object
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.
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_overrides ⇒ Object
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(&:underscore) ledger_resource_type_overrides.invert[converter.call(type).to_sym] || resources[converter.call(type).to_sym] end |
#resources ⇒ Object
105 106 107 |
# File 'lib/ledger_sync/ledgers/client.rb', line 105 def resources @resources ||= {} end |
#root_key ⇒ Object
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 |