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.
132 133 134 135 136 137 |
# File 'lib/rubber/environment.rb', line 132 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
159 160 161 162 |
# File 'lib/rubber/environment.rb', line 159 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.
130 131 132 |
# File 'lib/rubber/environment.rb', line 130 def host @host end |
#roles ⇒ Object (readonly)
Returns the value of attribute roles.
129 130 131 |
# File 'lib/rubber/environment.rb', line 129 def roles @roles end |
Instance Method Details
#bind_config(global) ⇒ Object
Forces role/host overrides into config
144 145 146 147 148 149 150 151 152 153 154 155 156 157 |
# File 'lib/rubber/environment.rb', line 144 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 |
#full_host ⇒ Object
139 140 141 |
# File 'lib/rubber/environment.rb', line 139 def full_host @full_host ||= "#{host}.#{domain}" rescue nil end |