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(&block) ⇒ 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.
121 122 123 124 125 |
# File 'lib/engineyard/config.rb', line 121 def initialize(config, name, parent) @config = config || {} @name = name @parent = parent end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
119 120 121 |
# File 'lib/engineyard/config.rb', line 119 def name @name end |
Instance Method Details
#branch ⇒ Object
153 154 155 |
# File 'lib/engineyard/config.rb', line 153 def branch fetch('branch', nil) end |
#fetch(key, default = nil, &block) ⇒ Object
131 132 133 134 135 136 137 |
# File 'lib/engineyard/config.rb', line 131 def fetch(key, default = nil, &block) if block @config.fetch(key.to_s, &block) else @config.fetch(key.to_s, default) end end |
#merge(other) ⇒ Object
145 146 147 |
# File 'lib/engineyard/config.rb', line 145 def merge(other) to_clean_hash.merge(other) end |
#migrate(&block) ⇒ Object
157 158 159 |
# File 'lib/engineyard/config.rb', line 157 def migrate(&block) fetch('migrate', &block) end |
#migrate=(mig) ⇒ Object
161 162 163 |
# File 'lib/engineyard/config.rb', line 161 def migrate=(mig) set('migrate', mig) end |
#migration_command ⇒ Object Also known as: migrate_command
165 166 167 |
# File 'lib/engineyard/config.rb', line 165 def migration_command fetch('migration_command', nil) end |
#migration_command=(cmd) ⇒ Object Also known as: migrate_command=
169 170 171 |
# File 'lib/engineyard/config.rb', line 169 def migration_command=(cmd) set('migration_command', cmd) end |
#path ⇒ Object
127 128 129 |
# File 'lib/engineyard/config.rb', line 127 def path @parent.path end |
#set(key, val) ⇒ Object
139 140 141 142 143 |
# File 'lib/engineyard/config.rb', line 139 def set(key, val) @config[key.to_s] = val @parent.set_environment_option(@name, key, val) val end |
#to_clean_hash ⇒ Object
149 150 151 |
# File 'lib/engineyard/config.rb', line 149 def to_clean_hash @config.reject { |k,v| %w[branch migrate migration_command verbose].include?(k) } end |
#verbose ⇒ Object
175 176 177 |
# File 'lib/engineyard/config.rb', line 175 def verbose fetch('verbose', false) end |