Sha256: 2073287de842f590911f19a683ac34cfeba49b2179fd2c3b8c8b78048ce09a5f
Contents?: true
Size: 1.01 KB
Versions: 1
Compression:
Stored size: 1.01 KB
Contents
module ShopSensor class Configuration Config = Struct.new 'Config', :api_key, :locale 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' } def initialize settings={} @config = Config.new set DEFAULTS.merge(settings) end def configure &block block.call @config self end def clear! set DEFAULTS end def site SITES[@config.locale.intern] end def clone self.class.new self.to_h end def to_h @config.to_h end private def method_missing method, *args return super unless @config.members.include? method @config.public_send method, *args end def set settings={} @config.members.each { |member| @config[member] = settings[member] } end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
shop_sensor-0.0.2 | lib/shop_sensor/configuration.rb |