Class: Optix::Configurator
- Inherits:
-
Object
- Object
- Optix::Configurator
- Defined in:
- lib/optix.rb
Instance Method Summary collapse
- #cloak(&b) ⇒ Object
-
#initialize(config, &b) ⇒ Configurator
constructor
A new instance of Configurator.
- #method_missing(meth, *args, &block) ⇒ Object
Constructor Details
#initialize(config, &b) ⇒ Configurator
Returns a new instance of Configurator.
175 176 177 178 |
# File 'lib/optix.rb', line 175 def initialize(config, &b) @config = config cloak(&b).bind(self).call end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(meth, *args, &block) ⇒ Object
180 181 182 183 184 185 |
# File 'lib/optix.rb', line 180 def method_missing(meth, *args, &block) unless @config.include? meth raise ArgumentError, "Unknown configuration key '#{meth}'" end @config[meth] = args[0] end |
Instance Method Details
#cloak(&b) ⇒ Object
187 188 189 190 191 192 193 194 |
# File 'lib/optix.rb', line 187 def cloak &b (class << self; self; end).class_eval do define_method :cloaker_, &b meth = instance_method :cloaker_ remove_method :cloaker_ meth end end |