Class: LedgerSync::AdaptorConfiguration

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(root_key, module_string: nil) ⇒ AdaptorConfiguration

Returns a new instance of AdaptorConfiguration.



24
25
26
27
28
# File 'lib/ledger_sync/adaptor_configuration.rb', line 24

def initialize(root_key, module_string: nil)
  @root_key = root_key
  @aliases = []
  @module_string = module_string || LedgerSync::Util::StringHelpers.camelcase(root_key)
end

Instance Attribute Details

#aliasesObject (readonly)

Returns the value of attribute aliases.



13
14
15
# File 'lib/ledger_sync/adaptor_configuration.rb', line 13

def aliases
  @aliases
end

#module_stringObject

Returns the value of attribute module_string.



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

def module_string
  @module_string
end

#nameObject

Returns the value of attribute name.



8
9
10
# File 'lib/ledger_sync/adaptor_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/adaptor_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.



13
14
15
# File 'lib/ledger_sync/adaptor_configuration.rb', line 13

def root_key
  @root_key
end

#testObject

Returns the value of attribute test.



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

def test
  @test
end

Instance Method Details

#adaptor_klassObject



30
31
32
# File 'lib/ledger_sync/adaptor_configuration.rb', line 30

def adaptor_klass
  @adaptor_klass ||= base_module::Adaptor
end

#add_alias(new_alias) ⇒ Object



34
35
36
37
# File 'lib/ledger_sync/adaptor_configuration.rb', line 34

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

#base_moduleObject



39
40
41
42
43
# File 'lib/ledger_sync/adaptor_configuration.rb', line 39

def base_module
  @base_module ||= begin
    LedgerSync::Adaptors.const_get(@module_string)
  end
end

#new(*args) ⇒ Object

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



47
48
49
# File 'lib/ledger_sync/adaptor_configuration.rb', line 47

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

#new_from_env(*args) ⇒ Object

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



53
54
55
# File 'lib/ledger_sync/adaptor_configuration.rb', line 53

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

#test?Boolean

Returns:

  • (Boolean)


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

def test?
  test == true
end