Class: Rubber::Configuration::Environment::BoundEnv
- Inherits:
-
HashValueProxy
- Object
- Hash
- HashValueProxy
- Rubber::Configuration::Environment::BoundEnv
- Defined in:
- lib/rubber/environment.rb
Instance Attribute Summary collapse
-
#full_host ⇒ Object
readonly
Returns the value of attribute full_host.
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#roles ⇒ Object
readonly
Returns the value of attribute roles.
Attributes inherited from HashValueProxy
Instance Method Summary collapse
-
#bind_config(global) ⇒ Object
Forces role/host overrides into config.
-
#initialize(global, roles, host) ⇒ BoundEnv
constructor
A new instance of BoundEnv.
- #method_missing(method_id) ⇒ Object
Methods inherited from HashValueProxy
#[], #each, #expand, #expand_string
Constructor Details
#initialize(global, roles, host) ⇒ BoundEnv
127 128 129 130 131 132 133 |
# File 'lib/rubber/environment.rb', line 127 def initialize(global, roles, host) @roles = roles @host = host bound_global = bind_config(global) super(nil, bound_global) @full_host = "#{host}.#{domain}" rescue nil end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_id) ⇒ Object
151 152 153 154 |
# File 'lib/rubber/environment.rb', line 151 def method_missing(method_id) key = method_id.id2name return self[key] end |
Instance Attribute Details
#full_host ⇒ Object (readonly)
Returns the value of attribute full_host.
125 126 127 |
# File 'lib/rubber/environment.rb', line 125 def full_host @full_host end |
#host ⇒ Object (readonly)
Returns the value of attribute host.
124 125 126 |
# File 'lib/rubber/environment.rb', line 124 def host @host end |
#roles ⇒ Object (readonly)
Returns the value of attribute roles.
123 124 125 |
# File 'lib/rubber/environment.rb', line 123 def roles @roles end |
Instance Method Details
#bind_config(global) ⇒ Object
Forces role/host overrides into config
136 137 138 139 140 141 142 143 144 145 146 147 148 149 |
# File 'lib/rubber/environment.rb', line 136 def bind_config(global) global = global.clone() role_overrides = global.delete("roles") || {} host_overrides = global.delete("hosts") || {} roles.to_a.each do |role| role_overrides[role].each do |k, v| global[k] = Environment.combine(global[k], v) end if role_overrides[role] end host_overrides[host].each do |k, v| global[k] = Environment.combine(global[k], v) end if host_overrides[host] return global end |