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.



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

#nameObject (readonly)

Returns the value of attribute name.



119
120
121
# File 'lib/engineyard/config.rb', line 119

def name
  @name
end

Instance Method Details

#branchObject



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_commandObject 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

#pathObject



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_hashObject



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

#verboseObject



175
176
177
# File 'lib/engineyard/config.rb', line 175

def verbose
  fetch('verbose', false)
end