Class: Config
- Inherits:
-
Object
- Object
- Config
- Defined in:
- lib/config.rb
Instance Attribute Summary collapse
-
#contexts ⇒ Object
Returns the value of attribute contexts.
-
#environments ⇒ Object
Returns the value of attribute environments.
-
#requests ⇒ Object
Returns the value of attribute requests.
Class Method Summary collapse
Instance Method Summary collapse
- #get_context(ctx_name) ⇒ Object
- #get_environment(env_name) ⇒ Object
- #get_request(env_name) ⇒ Object
- #has_context?(ctx_name) ⇒ Boolean
- #has_environment?(env_name) ⇒ Boolean
- #has_request?(env_name) ⇒ Boolean
-
#initialize(hash) ⇒ Config
constructor
A new instance of Config.
Constructor Details
#initialize(hash) ⇒ Config
Returns a new instance of Config.
5 6 7 8 9 10 11 12 13 14 |
# File 'lib/config.rb', line 5 def initialize(hash) @contexts = hash[:contexts] || hash['contexts'] || {} @contexts = @contexts.map {|ctx| Context.new(ctx) } @environments = hash[:environments] || hash['environments'] || {} @environments = @environments.map { |env| Environment.new(env) } @requests = hash[:requests] || hash['requests'] || {} @requests = @requests.map { |req| Request.new(req) } end |
Instance Attribute Details
#contexts ⇒ Object
Returns the value of attribute contexts.
3 4 5 |
# File 'lib/config.rb', line 3 def contexts @contexts end |
#environments ⇒ Object
Returns the value of attribute environments.
3 4 5 |
# File 'lib/config.rb', line 3 def environments @environments end |
#requests ⇒ Object
Returns the value of attribute requests.
3 4 5 |
# File 'lib/config.rb', line 3 def requests @requests end |
Class Method Details
Instance Method Details
#get_context(ctx_name) ⇒ Object
24 25 26 |
# File 'lib/config.rb', line 24 def get_context(ctx_name) @contexts.find {|ctx| ctx.name == ctx_name } end |
#get_environment(env_name) ⇒ Object
32 33 34 |
# File 'lib/config.rb', line 32 def get_environment(env_name) @environments.find {|env| env.name == env_name } end |
#get_request(env_name) ⇒ Object
40 41 42 |
# File 'lib/config.rb', line 40 def get_request(env_name) @requests.find {|env| env.name == env_name } end |
#has_context?(ctx_name) ⇒ Boolean
20 21 22 |
# File 'lib/config.rb', line 20 def has_context?(ctx_name) @contexts.any? {|ctx| ctx.name == ctx_name } end |
#has_environment?(env_name) ⇒ Boolean
28 29 30 |
# File 'lib/config.rb', line 28 def has_environment?(env_name) @environments.any? {|env| env.name == env_name } end |
#has_request?(env_name) ⇒ Boolean
36 37 38 |
# File 'lib/config.rb', line 36 def has_request?(env_name) @requests.any? {|env| env.name == env_name } end |