Class: LedgerSync::LedgerConfiguration

Inherits:
Object
  • Object
show all
Includes:
Fingerprintable::Mixin, SimplySerializable::Mixin
Defined in:
lib/ledger_sync/ledger_configuration.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(root_key, args = {}) ⇒ LedgerConfiguration

Returns a new instance of LedgerConfiguration.



25
26
27
28
29
30
31
32
33
34
# File 'lib/ledger_sync/ledger_configuration.rb', line 25

def initialize(root_key, args = {})
  @root_key = root_key
  @aliases = []
  @root_path = args.fetch(:root_path, "ledger_sync/ledgers/#{root_key}")

  require client_path

  @base_module = args.fetch(:base_module, nil)
  @base_module ||= LedgerSync::Ledgers.const_get(LedgerSync::Util::StringHelpers.camelcase(root_key))
end

Instance Attribute Details

#aliasesObject (readonly)

Returns the value of attribute aliases.



12
13
14
# File 'lib/ledger_sync/ledger_configuration.rb', line 12

def aliases
  @aliases
end

#base_moduleObject (readonly)

Returns the value of attribute base_module.



12
13
14
# File 'lib/ledger_sync/ledger_configuration.rb', line 12

def base_module
  @base_module
end

#nameObject

Returns the value of attribute name.



8
9
10
# File 'lib/ledger_sync/ledger_configuration.rb', line 8

def name
  @name
end

#rate_limiting_wait_in_secondsObject

Returns the value of attribute rate_limiting_wait_in_seconds.



8
9
10
# File 'lib/ledger_sync/ledger_configuration.rb', line 8

def rate_limiting_wait_in_seconds
  @rate_limiting_wait_in_seconds
end

#root_keyObject (readonly)

Returns the value of attribute root_key.



12
13
14
# File 'lib/ledger_sync/ledger_configuration.rb', line 12

def root_key
  @root_key
end

#root_pathObject (readonly)

Returns the value of attribute root_path.



12
13
14
# File 'lib/ledger_sync/ledger_configuration.rb', line 12

def root_path
  @root_path
end

#testObject

Returns the value of attribute test.



8
9
10
# File 'lib/ledger_sync/ledger_configuration.rb', line 8

def test
  @test
end

Instance Method Details

#add_alias(new_alias) ⇒ Object



44
45
46
47
# File 'lib/ledger_sync/ledger_configuration.rb', line 44

def add_alias(new_alias)
  @aliases << new_alias
  LedgerSync.ledgers.add_alias(new_alias, self)
end

#client_classObject



36
37
38
# File 'lib/ledger_sync/ledger_configuration.rb', line 36

def client_class
  @client_class ||= base_module::Client
end

#client_pathObject



40
41
42
# File 'lib/ledger_sync/ledger_configuration.rb', line 40

def client_path
  @client_path ||= File.join(root_path, 'client')
end

#new(*args) ⇒ Object

Delegate #new to the client class enabling faster client initialization e.g. LedgerSync.ledgers.test.new(…)



51
52
53
# File 'lib/ledger_sync/ledger_configuration.rb', line 51

def new(*args)
  client_class.new(*args)
end

#new_from_env(*args) ⇒ Object

Delegate #new_from_env to the client class enabling faster client initialization e.g. LedgerSync.ledgers.test.new_from_env(…)



57
58
59
# File 'lib/ledger_sync/ledger_configuration.rb', line 57

def new_from_env(*args)
  client_class.new_from_env(*args)
end

#test?Boolean

Returns:

  • (Boolean)


61
62
63
# File 'lib/ledger_sync/ledger_configuration.rb', line 61

def test?
  test == true
end