Module: RCreds

Defined in:
lib/r_creds.rb,
lib/r_creds/fetcher.rb,
lib/r_creds/version.rb,
lib/generators/r_creds/install_generator.rb

Defined Under Namespace

Modules: Generators Classes: Fetcher, InvalidTypeError

Constant Summary collapse

VERSION =
'1.3.0'

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.allow_nil_valueObject



16
17
18
# File 'lib/r_creds.rb', line 16

def allow_nil_value
  @allow_nil_value || true
end

.environment_firstObject



12
13
14
# File 'lib/r_creds.rb', line 12

def environment_first
  @environment_first || false
end

Class Method Details

.config {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:

  • _self (RCreds)

    the object that the method was called on



20
21
22
# File 'lib/r_creds.rb', line 20

def config
  yield self
end

.fetch(*keys, default: nil, environment: nil, environment_first: self.environment_first, allow_nil_value: self.allow_nil_value) ⇒ Object



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

def fetch(*keys,
          default: nil,
          environment: nil,
          environment_first: self.environment_first,
          allow_nil_value: self.allow_nil_value)

  [environment_first, allow_nil_value].each do |attr|
    invalid_type_error! unless [true, false].include?(attr)
  end

  Fetcher.new(keys, default, environment, environment_first, allow_nil_value).call
end