Class: ENVV::Builder
- Inherits:
-
Object
- Object
- ENVV::Builder
- Defined in:
- lib/envv/builder.rb
Instance Attribute Summary collapse
-
#env ⇒ Object
readonly
Returns the value of attribute env.
-
#schema ⇒ Object
readonly
Returns the value of attribute schema.
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(env, schema) ⇒ Builder
constructor
A new instance of Builder.
Constructor Details
#initialize(env, schema) ⇒ Builder
Returns a new instance of Builder.
20 21 22 23 |
# File 'lib/envv/builder.rb', line 20 def initialize(env, schema) @env = env @schema = schema end |
Instance Attribute Details
#env ⇒ Object (readonly)
Returns the value of attribute env.
8 9 10 |
# File 'lib/envv/builder.rb', line 8 def env @env end |
#schema ⇒ Object (readonly)
Returns the value of attribute schema.
8 9 10 |
# File 'lib/envv/builder.rb', line 8 def schema @schema end |
Class Method Details
.call(env, schema = nil) ⇒ Object
11 12 13 |
# File 'lib/envv/builder.rb', line 11 def call(env, schema = nil) new(env, schema).call end |
.to_proc ⇒ Object
15 16 17 |
# File 'lib/envv/builder.rb', line 15 def to_proc method(:call).to_proc end |
Instance Method Details
#call ⇒ Object
25 26 27 28 29 30 31 32 33 34 |
# File 'lib/envv/builder.rb', line 25 def call validate_params! result = @schema.call(extract_env_vars) if result.failure? raise ValidationError, result.errors(full: true).to_h.values.flatten else ENVV::Registry[result.to_h.transform_keys(&:to_s)].freeze end end |