Class: Bento::Configuration
- Inherits:
-
Object
- Object
- Bento::Configuration
show all
- Defined in:
- lib/bento/sdk/configuration.rb
Constant Summary
collapse
- DEFAULT_CONFIGURATION =
{
site_uuid: nil,
publishable_key: nil,
secret_key: nil,
dev_mode: false,
sync_strategy: nil,
sync_strategy_options: {},
log_level: :warn,
}.freeze
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
Returns a new instance of Configuration.
[View source]
13
14
15
16
17
|
# File 'lib/bento/sdk/configuration.rb', line 13
def initialize(config_from_initialize = {})
@config = default_config
.merge(config_from_initialize)
.merge(config_from_environment)
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
permalink
#method_missing(name, *args, &block) ⇒ Object
[View source]
74
75
76
77
78
79
80
81
82
83
|
# File 'lib/bento/sdk/configuration.rb', line 74
def method_missing(name, *args, &block)
if respond_to_missing?(name)
name = name.to_s
method = name =~ /=$/ ? :[]= : :[]
name = name.sub(/=$/, '').to_sym
send(method, name, *args, &block)
else
super
end
end
|
Class Method Details
permalink
.inherit(parent, config_from_arguments) ⇒ Object
[View source]
19
20
21
22
23
24
|
# File 'lib/bento/sdk/configuration.rb', line 19
def self.inherit(parent, config_from_arguments)
config = allocate
config.instance_variable_set(:@parent, parent)
config.instance_variable_set(:@config, config_from_arguments.to_hash)
config
end
|
Instance Method Details
permalink
#==(other) ⇒ Object
[View source]
38
39
40
|
# File 'lib/bento/sdk/configuration.rb', line 38
def ==(other)
config == other.config && parent == other.parent
end
|
permalink
#merge(other_config) ⇒ Object
[View source]
26
27
28
|
# File 'lib/bento/sdk/configuration.rb', line 26
def merge(other_config)
self.class.inherit(self, other_config)
end
|
[View source]
34
35
36
|
# File 'lib/bento/sdk/configuration.rb', line 34
def to_h
parent ? parent.to_h.merge(config) : to_hash
end
|
[View source]
30
31
32
|
# File 'lib/bento/sdk/configuration.rb', line 30
def to_hash
config
end
|