Module: ContainerConfig::Coercer
- Defined in:
- lib/container_config/coercer.rb,
lib/container_config/coercer/base.rb,
lib/container_config/coercer/float.rb,
lib/container_config/coercer/string.rb,
lib/container_config/coercer/symbol.rb,
lib/container_config/coercer/boolean.rb,
lib/container_config/coercer/integer.rb,
lib/container_config/coercer/ssl_key.rb,
lib/container_config/coercer/ssl_certificate.rb,
lib/container_config/coercer/ssl_verify_mode.rb
Overview
Contains classes and methods for type coercion
Defined Under Namespace
Classes: Base, Boolean, Float, Integer, SslCertificate, SslKey, SslVerifyMode, String, Symbol
Class Method Summary collapse
-
.coerce_value(value, value_type = nil, options = {}) ⇒ Object
Coerces a given value into a requested type.
-
.default_coercers ⇒ Array<ContainerConfig::Coercer::Base>
Array of default coercers.
Class Method Details
.coerce_value(value, value_type = nil, options = {}) ⇒ Object
Coerces a given value into a requested type
28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/container_config/coercer.rb', line 28 def self.coerce_value(value, value_type = nil, = {}) return value unless value_type return value if [:coerce_nil] == false && value.nil? value_type = value_type.to_sym ContainerConfig.coercers.each do |coercer| return coercer.coerce(value) if coercer.type == value_type end ContainerConfig.logger.warn { "Could not find valid coercion type for #{value_type}" } value end |
.default_coercers ⇒ Array<ContainerConfig::Coercer::Base>
Array of default coercers
48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/container_config/coercer.rb', line 48 def self.default_coercers [ ContainerConfig::Coercer::Boolean.new, ContainerConfig::Coercer::Float.new, ContainerConfig::Coercer::Integer.new, ContainerConfig::Coercer::SslCertificate.new, ContainerConfig::Coercer::SslKey.new, ContainerConfig::Coercer::SslVerifyMode.new, ContainerConfig::Coercer::String.new, ContainerConfig::Coercer::Symbol.new ] end |