Class: Ricordami::Config
- Inherits:
-
Object
- Object
- Ricordami::Config
- Defined in:
- lib/ricordami/configuration.rb
Constant Summary collapse
- ATTRIBUTE_NAMES =
[:redis_host, :redis_port, :redis_db, :thread_safe]
Instance Method Summary collapse
- #from_hash(options) ⇒ Object
-
#initialize ⇒ Config
constructor
A new instance of Config.
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
20 21 22 |
# File 'lib/ricordami/configuration.rb', line 20 def initialize @options = {} end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(meth, *args, &blk) ⇒ Object (private)
30 31 32 33 34 35 36 37 |
# File 'lib/ricordami/configuration.rb', line 30 def method_missing(meth, *args, &blk) return @options[meth] if ATTRIBUTE_NAMES.include?(meth) if args.length == 1 && match = /^(.*)=$/.match(meth.to_s) name = match[1].to_sym return @options[name] = args.first if ATTRIBUTE_NAMES.include?(name) end raise AttributeNotSupported.new("attribute #{meth.to_s.inspect} is not supported") end |
Instance Method Details
#from_hash(options) ⇒ Object
24 25 26 |
# File 'lib/ricordami/configuration.rb', line 24 def from_hash() @options = .slice(*ATTRIBUTE_NAMES) end |