Module: LedgerSync

Includes:
Util::Mixins::ResourceRegisterableMixin
Defined in:
lib/ledger_sync/version.rb,
lib/ledger_sync.rb,
lib/ledger_sync/error.rb,
lib/ledger_sync/result.rb,
lib/ledger_sync/type/id.rb,
lib/ledger_sync/resource.rb,
lib/ledger_sync/operation.rb,
lib/ledger_sync/type/date.rb,
lib/ledger_sync/type/hash.rb,
lib/ledger_sync/serializer.rb,
lib/ledger_sync/type/float.rb,
lib/ledger_sync/type/value.rb,
lib/ledger_sync/type/string.rb,
lib/ledger_sync/util/signer.rb,
lib/ledger_sync/deserializer.rb,
lib/ledger_sync/test/support.rb,
lib/ledger_sync/type/boolean.rb,
lib/ledger_sync/type/integer.rb,
lib/ledger_sync/ledgers/client.rb,
lib/ledger_sync/util/performer.rb,
lib/ledger_sync/util/validator.rb,
lib/ledger_sync/ledgers/request.rb,
lib/ledger_sync/ledgers/contract.rb,
lib/ledger_sync/ledgers/response.rb,
lib/ledger_sync/ledgers/searcher.rb,
lib/ledger_sync/type/value_mixin.rb,
lib/ledger_sync/util/url_helpers.rb,
lib/ledger_sync/ledgers/operation.rb,
lib/ledger_sync/util/hash_helpers.rb,
lib/ledger_sync/resource_attribute.rb,
lib/ledger_sync/type/reference_one.rb,
lib/ledger_sync/error/ledger_errors.rb,
lib/ledger_sync/serialization/mixin.rb,
lib/ledger_sync/type/reference_many.rb,
lib/ledger_sync/util/dotenv_updator.rb,
lib/ledger_sync/util/string_helpers.rb,
lib/ledger_sync/concerns/validatable.rb,
lib/ledger_sync/ledger_configuration.rb,
lib/ledger_sync/type/string_from_set.rb,
lib/ledger_sync/error/resource_errors.rb,
lib/ledger_sync/util/read_only_object.rb,
lib/ledger_sync/error/operation_errors.rb,
lib/ledger_sync/resource_attribute_set.rb,
lib/ledger_sync/util/resources_builder.rb,
lib/ledger_sync/serialization/attribute.rb,
lib/ledger_sync/util/resource_converter.rb,
lib/ledger_sync/resource_attribute/mixin.rb,
lib/ledger_sync/util/mixins/dupable_mixin.rb,
lib/ledger_sync/ledger_configuration_store.rb,
lib/ledger_sync/ledgers/dashboard_url_helper.rb,
lib/ledger_sync/resource_attribute/reference.rb,
lib/ledger_sync/resource_attribute/dirty_mixin.rb,
lib/ledger_sync/test/support/qa/ledger_helpers.rb,
lib/ledger_sync/test/support/record_collection.rb,
lib/ledger_sync/serialization/type/mapping_type.rb,
lib/ledger_sync/test/support/test_ledger/client.rb,
lib/ledger_sync/resource_attribute/reference/one.rb,
lib/ledger_sync/test/support/test_ledger/webhook.rb,
lib/ledger_sync/ledgers/mixins/infer_config_mixin.rb,
lib/ledger_sync/resource_attribute/reference/many.rb,
lib/ledger_sync/serialization/attribute_set_mixin.rb,
lib/ledger_sync/test/support/test_ledger/resource.rb,
lib/ledger_sync/test/support/test_ledger/searcher.rb,
lib/ledger_sync/util/resource_converter/attribute.rb,
lib/ledger_sync/ledgers/mixins/serialization_mixin.rb,
lib/ledger_sync/serialization/serializer_attribute.rb,
lib/ledger_sync/serialization/type/parse_date_type.rb,
lib/ledger_sync/serialization/type/serializer_type.rb,
lib/ledger_sync/test/support/test_ledger/operation.rb,
lib/ledger_sync/serialization/type/format_date_type.rb,
lib/ledger_sync/test/support/test_ledger/serializer.rb,
lib/ledger_sync/serialization/deserializer_attribute.rb,
lib/ledger_sync/serialization/type/deserializer_type.rb,
lib/ledger_sync/ledgers/mixins/infer_serializer_mixin.rb,
lib/ledger_sync/test/support/test_ledger/deserializer.rb,
lib/ledger_sync/util/resource_converter/attribute_set.rb,
lib/ledger_sync/serialization/serializer_attribute_set.rb,
lib/ledger_sync/test/support/test_ledger/webhook_event.rb,
lib/ledger_sync/test/support/test_ledger/operation/find.rb,
lib/ledger_sync/util/mixins/resource_registerable_mixin.rb,
lib/ledger_sync/serialization/deserializer_attribute_set.rb,
lib/ledger_sync/ledgers/mixins/infer_resource_class_mixin.rb,
lib/ledger_sync/test/support/test_ledger/operation/create.rb,
lib/ledger_sync/test/support/test_ledger/operation/update.rb,
lib/ledger_sync/test/support/test_ledger/customer/searcher.rb,
lib/ledger_sync/test/support/test_ledger/util/error_parser.rb,
lib/ledger_sync/test/support/test_ledger/resources/customer.rb,
lib/ledger_sync/test/support/test_ledger/util/error_matcher.rb,
lib/ledger_sync/util/mixins/delegate_iterable_methods_mixin.rb,
lib/ledger_sync/test/support/test_ledger/customer/serializer.rb,
lib/ledger_sync/test/support/test_ledger/subsidiary/searcher.rb,
lib/ledger_sync/test/support/test_ledger/resources/subsidiary.rb,
lib/ledger_sync/test/support/test_ledger/webhook_notification.rb,
lib/ledger_sync/ledgers/mixins/infer_validation_contract_mixin.rb,
lib/ledger_sync/test/support/test_ledger/customer/deserializer.rb,
lib/ledger_sync/test/support/test_ledger/subsidiary/serializer.rb,
lib/ledger_sync/test/support/test_ledger/subsidiary/deserializer.rb,
lib/ledger_sync/util/resource_converter/type/references_one_type.rb,
lib/ledger_sync/serialization/type/serializer_references_one_type.rb,
lib/ledger_sync/test/support/test_ledger/customer/operations/find.rb,
lib/ledger_sync/test/support/test_ledger/util/ledger_error_parser.rb,
lib/ledger_sync/util/resource_converter/type/references_many_type.rb,
lib/ledger_sync/serialization/type/serializer_references_many_type.rb,
lib/ledger_sync/serialization/type/deserializer_references_one_type.rb,
lib/ledger_sync/test/support/test_ledger/customer/operations/create.rb,
lib/ledger_sync/test/support/test_ledger/customer/operations/update.rb,
lib/ledger_sync/serialization/type/deserializer_references_many_type.rb,
lib/ledger_sync/test/support/test_ledger/util/operation_error_parser.rb,
lib/ledger_sync/util/resource_converter/type/resource_converter_type.rb,
lib/ledger_sync/ledgers/mixins/offset_and_limit_pagination_searcher_mixin.rb,
lib/ledger_sync/test/support/test_ledger/subsidiary/searcher_deserializer.rb

Overview

Defined Under Namespace

Modules: Ledgers, ResultBase, Serialization, Test, Type, Util, Validatable Classes: Deserializer, Error, LedgerConfiguration, LedgerConfigurationStore, Operation, OperationResult, Resource, ResourceAttribute, ResourceAttributeError, ResourceAttributeSet, ResourceError, Result, SearchResult, Serializer, ValidationResult

Constant Summary collapse

LEVEL_DEBUG =

map to the same values as the standard library’s logger

Logger::DEBUG
LEVEL_ERROR =
Logger::ERROR
LEVEL_INFO =
Logger::INFO
VERSION =
'2.4.4'

Class Method Summary collapse

Methods included from Util::Mixins::ResourceRegisterableMixin

included

Class Method Details

.ledgersObject



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

def self.ledgers
  @ledgers ||= LedgerSync::LedgerConfigurationStore.new
end

.log_levelObject



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

def self.log_level
  @log_level
end

.log_level=(val) ⇒ Object



94
95
96
97
98
99
100
# File 'lib/ledger_sync.rb', line 94

def self.log_level=(val)
  if !val.nil? && ![LEVEL_DEBUG, LEVEL_ERROR, LEVEL_INFO].include?(val)
    raise ArgumentError, 'log_level should only be set to `nil`, `debug` or `info`'
  end

  @log_level = val
end

.loggerObject



102
103
104
# File 'lib/ledger_sync.rb', line 102

def self.logger
  @logger
end

.logger=(val) ⇒ Object



106
107
108
# File 'lib/ledger_sync.rb', line 106

def self.logger=(val)
  @logger = val
end

.register_ledger(*args) {|ledger_config| ... } ⇒ Object

Yields:

  • (ledger_config)


110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
# File 'lib/ledger_sync.rb', line 110

def self.register_ledger(*args)
  ledger_config = LedgerSync::LedgerConfiguration.new(*args)

  yield(ledger_config)

  ledgers.register_ledger(ledger_config: ledger_config)

  client_files = Gem.find_files("#{ledger_config.root_path}/resource.rb")
  client_files |= Gem.find_files("#{ledger_config.root_path}/resources/**/*.rb")
  client_files |= Gem.find_files("#{ledger_config.root_path}/serialization/**/*.rb")
  # Sort the files to include BFS-style as most dependencies are in parent folders
  client_files |= Gem.find_files("#{ledger_config.root_path}/**/*.rb").sort { |a, b| a.count('/') <=> b.count('/') }

  client_files.each do |path|
    next if path.include?('config.rb')

    require path
  end
end

.rootObject



130
131
132
# File 'lib/ledger_sync.rb', line 130

def self.root
  File.dirname __dir__
end

.versionObject



7
8
9
10
11
12
13
# File 'lib/ledger_sync/version.rb', line 7

def self.version
  if ENV['PRE_RELEASE']
    "#{VERSION}.pre.#{ENV['GITHUB_RUN_NUMBER']}"
  else
    VERSION
  end
end