Class: Breadboard::Config::Environment
- Inherits:
-
Object
- Object
- Breadboard::Config::Environment
- Defined in:
- lib/breadboard/environment.rb
Instance Method Summary collapse
-
#initialize ⇒ Environment
constructor
A new instance of Environment.
- #method_missing(method_name, *args, &block) ⇒ Object
- #test(url = nil, &block) ⇒ Object
Constructor Details
#initialize ⇒ Environment
Returns a new instance of Environment.
4 5 6 |
# File 'lib/breadboard/environment.rb', line 4 def initialize @environments = {} end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args, &block) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/breadboard/environment.rb', line 19 def method_missing(method_name, *args, &block) if block_given? @environments[method_name] ||= EnvConfig.new @environments[method_name].instance_eval &block else if args.length == 0 @environments[method_name] else @environments[method_name] ||= EnvConfig.new @environments[method_name].site URI.parse args.first end end end |
Instance Method Details
#test(url = nil, &block) ⇒ Object
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/breadboard/environment.rb', line 8 def test(url=nil, &block) return @environments[:test] if url.nil? @environments[:test] ||= EnvConfig.new if block_given? @environments[:test].instance_eval block else @environments[:test].site URI.parse(url) end end |