Module: Hanami::Port Private
- Defined in:
- lib/hanami/port.rb
Overview
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
Constant Summary collapse
- DEFAULT =
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.
2300
- ENV_VAR =
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.
"HANAMI_PORT"
Class Method Summary collapse
- .call(value, env = ENV.fetch(ENV_VAR, nil)) ⇒ Object (also: []) private
- .call!(value) ⇒ Object private
- .default?(value) ⇒ Boolean private
Class Method Details
.call(value, env = ENV.fetch(ENV_VAR, nil)) ⇒ Object Also known as: []
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.
17 18 19 20 21 22 23 |
# File 'lib/hanami/port.rb', line 17 def self.call(value, env = ENV.fetch(ENV_VAR, nil)) return Integer(value) if !value.nil? && !default?(value) return Integer(env) unless env.nil? return Integer(value) unless value.nil? DEFAULT end |
.call!(value) ⇒ 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.
27 28 29 30 31 |
# File 'lib/hanami/port.rb', line 27 def self.call!(value) return if default?(value) ENV[ENV_VAR] = value.to_s end |
.default?(value) ⇒ Boolean
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.
35 36 37 |
# File 'lib/hanami/port.rb', line 35 def self.default?(value) value.to_i == DEFAULT end |