Class: CommonConfig::Scope
- Inherits:
-
Object
- Object
- CommonConfig::Scope
- Defined in:
- lib/ruby-app/common_config.rb
Instance Attribute Summary collapse
-
#configs ⇒ Object
readonly
Returns the value of attribute configs.
Instance Method Summary collapse
-
#initialize ⇒ Scope
constructor
A new instance of Scope.
Constructor Details
#initialize ⇒ Scope
Returns a new instance of Scope.
35 36 37 |
# File 'lib/ruby-app/common_config.rb', line 35 def initialize @configs = {} end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *params, &block) ⇒ Object (private)
43 44 45 46 47 48 49 50 51 |
# File 'lib/ruby-app/common_config.rb', line 43 def method_missing(name, *params, &block) if name.to_s =~ /_address$/i require 'ostruct' @configs[name.to_sym] = block || OpenStruct.new(:host => params[0], :port => params[1].to_i) else params = params[0] if params.size == 1 @configs[name.to_sym] = block || params end end |
Instance Attribute Details
#configs ⇒ Object (readonly)
Returns the value of attribute configs.
39 40 41 |
# File 'lib/ruby-app/common_config.rb', line 39 def configs @configs end |