Class: EY::Config::EnvironmentConfig

Inherits:
Object
  • Object
show all
Defined in:
lib/engineyard/config.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config, name, parent) ⇒ EnvironmentConfig

Returns a new instance of EnvironmentConfig.



155
156
157
158
159
# File 'lib/engineyard/config.rb', line 155

def initialize(config, name, parent)
  @config = config || {}
  @name = name
  @parent = parent
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



153
154
155
# File 'lib/engineyard/config.rb', line 153

def name
  @name
end

Instance Method Details

#branchObject



189
190
191
# File 'lib/engineyard/config.rb', line 189

def branch
  fetch('branch', nil)
end

#fetch(key, default = nil, &block) ⇒ Object



165
166
167
168
169
# File 'lib/engineyard/config.rb', line 165

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



181
182
183
# File 'lib/engineyard/config.rb', line 181

def merge(other)
  to_clean_hash.merge(other)
end

#migrateObject



193
194
195
# File 'lib/engineyard/config.rb', line 193

def migrate
  fetch('migrate')
end

#migrate=(mig) ⇒ Object



197
198
199
# File 'lib/engineyard/config.rb', line 197

def migrate=(mig)
  set('migrate', mig)
end

#migration_commandObject Also known as: migrate_command



201
202
203
# File 'lib/engineyard/config.rb', line 201

def migration_command
  fetch('migration_command', nil)
end

#migration_command=(cmd) ⇒ Object Also known as: migrate_command=



205
206
207
# File 'lib/engineyard/config.rb', line 205

def migration_command=(cmd)
  set('migration_command', cmd)
end

#pathObject



161
162
163
# File 'lib/engineyard/config.rb', line 161

def path
  @parent.path
end

#set(key, val) ⇒ Object



171
172
173
174
175
176
177
178
179
# File 'lib/engineyard/config.rb', line 171

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_hashObject



185
186
187
# File 'lib/engineyard/config.rb', line 185

def to_clean_hash
  @config.reject { |k,v| %w[branch migrate migration_command verbose].include?(k) }
end

#verboseObject



211
212
213
# File 'lib/engineyard/config.rb', line 211

def verbose
  fetch('verbose', false)
end