Class: AutoData::Env

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

Instance Method Summary collapse

Constructor Details

#initializeEnv

Returns a new instance of Env.



51
52
53
# File 'lib/auto_data.rb', line 51

def initialize()
  @env = ENV['CONF_ENV_TEST'].to_s.downcase
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method) ⇒ Object



70
71
72
73
74
75
76
# File 'lib/auto_data.rb', line 70

def method_missing (method)
  result= begin @file["#{@env}"]["#{method}"].nil? ? 'No Value Found' : @file["#{@env}"]["#{method}"]
  rescue NoMethodError => e
            puts "valdio dick #{e.message}"
  end
  result
end

Instance Method Details

#change_scope(env) ⇒ Object

Change environment key path



66
67
68
# File 'lib/auto_data.rb', line 66

def change_scope(env)
  @env=env.to_s.downcase
end

#load(file) ⇒ Object



55
56
57
58
59
60
61
62
63
64
# File 'lib/auto_data.rb', line 55

def load(file)
  #@file = YAML.load_file(file)

  @file = begin
            YAML.load(File.open(file))
          rescue Exception => e  #ArgumentError

              puts "Could not parse auto objects files: #{e.message}"
              e.exception('adsfasdfas')
          end
  #self

end

#valid_environment?Boolean

TODO: Validar si el cambio de env, es correcto (existe)

Returns:

  • (Boolean)


79
80
81
# File 'lib/auto_data.rb', line 79

def valid_environment?

end