Module: Pliny::CastingConfigHelpers
- Included in:
- Config
- Defined in:
- lib/pliny/config_helpers.rb
Instance Method Summary collapse
- #bool ⇒ Object
- #float ⇒ Object
- #int ⇒ Object
- #mandatory(name, method = nil) ⇒ Object
- #optional(name, method = nil) ⇒ Object
- #override(name, default, method = nil) ⇒ Object
- #string ⇒ Object
- #symbol ⇒ Object
Instance Method Details
#bool ⇒ Object
26 27 28 |
# File 'lib/pliny/config_helpers.rb', line 26 def bool ->(v) { v.to_s=='true'} end |
#float ⇒ Object
22 23 24 |
# File 'lib/pliny/config_helpers.rb', line 22 def float ->(v) { v.to_f } end |
#int ⇒ Object
18 19 20 |
# File 'lib/pliny/config_helpers.rb', line 18 def int ->(v) { v.to_i } end |
#mandatory(name, method = nil) ⇒ Object
3 4 5 6 |
# File 'lib/pliny/config_helpers.rb', line 3 def mandatory(name, method=nil) value = cast(ENV.fetch(name.to_s.upcase), method) create(name, value) end |
#optional(name, method = nil) ⇒ Object
8 9 10 11 |
# File 'lib/pliny/config_helpers.rb', line 8 def optional(name, method=nil) value = cast(ENV[name.to_s.upcase], method) create(name, value) end |
#override(name, default, method = nil) ⇒ Object
13 14 15 16 |
# File 'lib/pliny/config_helpers.rb', line 13 def override(name, default, method=nil) value = cast(ENV.fetch(name.to_s.upcase, default), method) create(name, value) end |
#string ⇒ Object
30 31 32 |
# File 'lib/pliny/config_helpers.rb', line 30 def string nil end |
#symbol ⇒ Object
34 35 36 |
# File 'lib/pliny/config_helpers.rb', line 34 def symbol ->(v) { v.to_sym } end |