Module: Kredentials

Defined in:
lib/kredentials/version.rb,
lib/kredentials/kredentials.rb

Constant Summary collapse

VERSION =
"0.1.0.1"

Class Method Summary collapse

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/kredentials/kredentials.rb', line 21

def method_missing(method)
  value =
      case self.config_env || Rails.env
        when 'production'
          self.production[method.to_sym]
        when 'staging'
          self.staging[method.to_sym] || self.development[method.to_sym]
        when 'test'
          self.test[method.to_sym]
        else
          self.development[method.to_sym]
      end
  return value || (self.class_variable_defined?('@@defaults') ?
      self.class_eval("@@defaults")[method.to_sym] : nil)
end

Class Method Details

.extended(cls) ⇒ Object



3
4
5
6
# File 'lib/kredentials/kredentials.rb', line 3

def self.extended(cls)
  cls.cattr_accessor(:config_env)
  cls.config_env = nil
end