Class: ShopSensor::Configuration
- Inherits:
-
Object
- Object
- ShopSensor::Configuration
show all
- Defined in:
- lib/shop_sensor/configuration.rb
Defined Under Namespace
Classes: Config
Constant Summary
collapse
- DEFAULTS =
{
locale: :en_US
}
- SITES =
{
en_US: 'www.shopstyle.com',
en_GB: 'www.shopstyle.co.uk',
fr_FR: 'www.shopstyle.fr',
de_DE: 'www.shopstyle.de',
ja_JP: 'www.shopstyle.co.jp',
en_AU: 'www.shopstyle.com.au',
en_CA: 'www.shopstyle.ca'
}
Instance Method Summary
collapse
Constructor Details
#initialize(settings = {}) ⇒ Configuration
Returns a new instance of Configuration.
18
19
20
21
|
# File 'lib/shop_sensor/configuration.rb', line 18
def initialize settings={}
@config = Config.new
set DEFAULTS.merge(settings)
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args) ⇒ Object
45
46
47
48
|
# File 'lib/shop_sensor/configuration.rb', line 45
def method_missing method, *args
return super unless @config.members.include? method
@config.public_send method, *args
end
|
Instance Method Details
#clear! ⇒ Object
28
29
30
|
# File 'lib/shop_sensor/configuration.rb', line 28
def clear!
set DEFAULTS
end
|
#clone ⇒ Object
36
37
38
|
# File 'lib/shop_sensor/configuration.rb', line 36
def clone
self.class.new self.to_h
end
|
23
24
25
26
|
# File 'lib/shop_sensor/configuration.rb', line 23
def configure &block
block.call @config
self
end
|
#site ⇒ Object
32
33
34
|
# File 'lib/shop_sensor/configuration.rb', line 32
def site
SITES[@config.locale.intern]
end
|
#to_h ⇒ Object
40
41
42
|
# File 'lib/shop_sensor/configuration.rb', line 40
def to_h
@config.to_h
end
|