Class: Hanami::Settings::EnvStore Private

Inherits:
Object
  • Object
show all
Defined in:
lib/hanami/settings/env_store.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

The default store for Hanami::Settings, loading setting values from ‘ENV`.

If your app loads the dotenv gem, then ‘ENV` will also be populated from various `.env` files when you subclass `Hanami::App`.

Since:

  • 2.0.0

Constant Summary collapse

NO_ARG =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

Since:

  • 2.0.0

Object.new.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(store: ENV, hanami_env: Hanami.env) ⇒ EnvStore

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of EnvStore.

Since:

  • 2.0.0



19
20
21
22
# File 'lib/hanami/settings/env_store.rb', line 19

def initialize(store: ENV, hanami_env: Hanami.env)
  @store = store
  @hanami_env = hanami_env
end

Instance Attribute Details

#hanami_envObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 2.0.0



17
18
19
# File 'lib/hanami/settings/env_store.rb', line 17

def hanami_env
  @hanami_env
end

#storeObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 2.0.0



17
18
19
# File 'lib/hanami/settings/env_store.rb', line 17

def store
  @store
end

Instance Method Details

#fetch(name, default_value = NO_ARG, &block) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 2.0.0



24
25
26
27
28
29
# File 'lib/hanami/settings/env_store.rb', line 24

def fetch(name, default_value = NO_ARG, &block)
  name = name.to_s.upcase
  args = default_value.eql?(NO_ARG) ? [name] : [name, default_value]

  store.fetch(*args, &block)
end