Class: Sinclair::EnvSettable::Builder Private

Inherits:
Sinclair show all
Defined in:
lib/sinclair/env_settable/builder.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.

Env setting methods builder

This builder does the magic of adding methods that will fetch variables from env or a default value

Author:

  • darthjee

Constant Summary

Constants inherited from Sinclair

VERSION

Instance Attribute Summary

Attributes inherited from Sinclair

#klass

Attributes included from OptionsParser

#options

Instance Method Summary collapse

Methods inherited from Sinclair

#add_class_method, #add_method, #build, build, #eval_and_add_method

Methods included from ClassMethods

#build

Methods included from OptionsParser

#options_object

Constructor Details

#initialize(klass, prefix, *settings_name, **defaults) ⇒ Builder

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 Builder.

Parameters:

  • klass (Class)

    Class that will receive the methods

  • prefix (String)

    Env keys prefix

  • settings_name (Array<Symbol,String>)

    Name of all settings to be added

  • defaults (Hash)

    Settings with default values



16
17
18
19
20
21
22
# File 'lib/sinclair/env_settable/builder.rb', line 16

def initialize(klass, prefix, *settings_name, **defaults)
  super(klass, prefix: prefix)

  @settings = Sinclair::InputHash.input_hash(*settings_name, **defaults)

  add_all_methods
end