Class: Dbmanager::Environment

Inherits:
OpenStruct
  • Object
show all
Defined in:
lib/dbmanager/environment.rb

Instance Method Summary collapse

Instance Method Details

#flag(attribute, flag) ⇒ Object

returns the flag formatted for the requested attribute, if present. env = Environment.new(:password => ‘secret’) env.flag(‘password’, ‘p’) # => -psecret env.flag(‘foo’, ‘f’) # => nil



34
35
36
37
# File 'lib/dbmanager/environment.rb', line 34

def flag(attribute, flag)
  value = send attribute
  "-#{flag}#{value}" if value.present?
end

#protected?Boolean

verifies whether the environment is protected from overwriting or not.

Returns:

  • (Boolean)


22
23
24
25
26
27
28
# File 'lib/dbmanager/environment.rb', line 22

def protected?
  if name =~ /production/
    protected != false
  else
    protected == true
  end
end