Class: Rubber::Configuration::Environment::BoundEnv
- Inherits:
-
HashValueProxy
- Object
- Hash
- HashValueProxy
- Rubber::Configuration::Environment::BoundEnv
- Defined in:
- lib/rubber/environment.rb
Instance Attribute Summary collapse
-
#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.
- #full_host ⇒ Object
-
#initialize(global, roles, host) ⇒ BoundEnv
constructor
A new instance of BoundEnv.
- #method_missing(method_id) ⇒ Object
Methods inherited from HashValueProxy
#[], #each, #expand, #expand_string, #rubber_instances
Constructor Details
#initialize(global, roles, host) ⇒ BoundEnv
Returns a new instance of BoundEnv.
140 141 142 143 144 145 |
# File 'lib/rubber/environment.rb', line 140 def initialize(global, roles, host) @roles = roles @host = host bound_global = bind_config(global) super(nil, bound_global) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_id) ⇒ Object
167 168 169 170 |
# File 'lib/rubber/environment.rb', line 167 def method_missing(method_id) key = method_id.id2name return self[key] end |
Instance Attribute Details
#host ⇒ Object (readonly)
Returns the value of attribute host.
138 139 140 |
# File 'lib/rubber/environment.rb', line 138 def host @host end |
#roles ⇒ Object (readonly)
Returns the value of attribute roles.
137 138 139 |
# File 'lib/rubber/environment.rb', line 137 def roles @roles end |
Instance Method Details
#bind_config(global) ⇒ Object
Forces role/host overrides into config
152 153 154 155 156 157 158 159 160 161 162 163 164 165 |
# File 'lib/rubber/environment.rb', line 152 def bind_config(global) global = global.clone() role_overrides = global.delete("roles") || {} host_overrides = global.delete("hosts") || {} Array(roles).each do |role| Array(role_overrides[role]).each do |k, v| global[k] = Environment.combine(global[k], v) end end Array(host_overrides[host]).each do |k, v| global[k] = Environment.combine(global[k], v) end return global end |
#full_host ⇒ Object
147 148 149 |
# File 'lib/rubber/environment.rb', line 147 def full_host @full_host ||= "#{host}.#{domain}" rescue nil end |