Class: Mech::Config
- Inherits:
-
Object
show all
- Includes:
- Singleton
- Defined in:
- lib/mech/config.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(variable, *args, &block) ⇒ Object
10
11
12
13
14
15
16
17
18
19
20
|
# File 'lib/mech/config.rb', line 10
def method_missing(variable, *args, &block)
if block_given?
args.unshift(self)
instance_variable_set("@#{variable}", lambda { block.call(*args) })
elsif args.size > 0
instance_variable_set("@#{variable}", args.shift)
else
value = instance_variable_get("@#{variable}")
value.respond_to?(:call) ? value.call : value
end
end
|
Class Method Details
.init(&block) ⇒ Object
6
7
8
|
# File 'lib/mech/config.rb', line 6
def self.init(&block)
instance.init(&block)
end
|
Instance Method Details
#env ⇒ Object
22
23
24
|
# File 'lib/mech/config.rb', line 22
def env
enviropment || nil
end
|
#init(&block) ⇒ Object
26
27
28
|
# File 'lib/mech/config.rb', line 26
def init(&block)
instance_eval(&block)
end
|