Class: EY::Config::EnvironmentConfig
- Inherits:
-
Object
- Object
- EY::Config::EnvironmentConfig
- Defined in:
- lib/engineyard/config.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #branch ⇒ Object
- #fetch(key, default = nil, &block) ⇒ Object
-
#initialize(config, name, parent) ⇒ EnvironmentConfig
constructor
A new instance of EnvironmentConfig.
- #merge(other) ⇒ Object
- #migrate ⇒ Object
- #migrate=(mig) ⇒ Object
- #migration_command ⇒ Object (also: #migrate_command)
- #migration_command=(cmd) ⇒ Object (also: #migrate_command=)
- #path ⇒ Object
- #set(key, val) ⇒ Object
- #to_clean_hash ⇒ Object
- #verbose ⇒ Object
Constructor Details
#initialize(config, name, parent) ⇒ EnvironmentConfig
Returns a new instance of EnvironmentConfig.
149 150 151 152 153 |
# File 'lib/engineyard/config.rb', line 149 def initialize(config, name, parent) @config = config || {} @name = name @parent = parent end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
147 148 149 |
# File 'lib/engineyard/config.rb', line 147 def name @name end |
Instance Method Details
#branch ⇒ Object
183 184 185 |
# File 'lib/engineyard/config.rb', line 183 def branch fetch('branch', nil) end |
#fetch(key, default = nil, &block) ⇒ Object
159 160 161 162 163 |
# File 'lib/engineyard/config.rb', line 159 def fetch(key, default = nil, &block) @config.fetch(key.to_s) do @parent.fetch_from_defaults(key.to_s, default, &block) end end |
#merge(other) ⇒ Object
175 176 177 |
# File 'lib/engineyard/config.rb', line 175 def merge(other) to_clean_hash.merge(other) end |
#migrate ⇒ Object
187 188 189 |
# File 'lib/engineyard/config.rb', line 187 def migrate fetch('migrate') end |
#migrate=(mig) ⇒ Object
191 192 193 |
# File 'lib/engineyard/config.rb', line 191 def migrate=(mig) set('migrate', mig) end |
#migration_command ⇒ Object Also known as: migrate_command
195 196 197 |
# File 'lib/engineyard/config.rb', line 195 def migration_command fetch('migration_command', nil) end |
#migration_command=(cmd) ⇒ Object Also known as: migrate_command=
199 200 201 |
# File 'lib/engineyard/config.rb', line 199 def migration_command=(cmd) set('migration_command', cmd) end |
#path ⇒ Object
155 156 157 |
# File 'lib/engineyard/config.rb', line 155 def path @parent.path end |
#set(key, val) ⇒ Object
165 166 167 168 169 170 171 172 173 |
# File 'lib/engineyard/config.rb', line 165 def set(key, val) if @config.empty? || !@config.has_key?(key.to_s) @parent.set_default_option(key, val) else @config[key.to_s] = val @parent.set_environment_option(@name, key, val) end val end |
#to_clean_hash ⇒ Object
179 180 181 |
# File 'lib/engineyard/config.rb', line 179 def to_clean_hash @config.reject { |k,v| %w[branch migrate migration_command verbose].include?(k) } end |
#verbose ⇒ Object
205 206 207 |
# File 'lib/engineyard/config.rb', line 205 def verbose fetch('verbose', false) end |