Class: Hackle::ParameterConfig
- Inherits:
-
Object
- Object
- Hackle::ParameterConfig
- Defined in:
- lib/hackle/internal/config/parameter_config.rb
Instance Attribute Summary collapse
- #parameters ⇒ Hash{String => Object} readonly
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object
- #get(key, default_value = nil) ⇒ Object?
-
#initialize(parameters) ⇒ ParameterConfig
constructor
A new instance of ParameterConfig.
- #to_s ⇒ Object
Constructor Details
#initialize(parameters) ⇒ ParameterConfig
Returns a new instance of ParameterConfig.
10 11 12 |
# File 'lib/hackle/internal/config/parameter_config.rb', line 10 def initialize(parameters) @parameters = parameters end |
Instance Attribute Details
#parameters ⇒ Hash{String => Object} (readonly)
7 8 9 |
# File 'lib/hackle/internal/config/parameter_config.rb', line 7 def parameters @parameters end |
Class Method Details
.empty ⇒ Hackle::ParameterConfig
17 18 19 |
# File 'lib/hackle/internal/config/parameter_config.rb', line 17 def self.empty @empty end |
Instance Method Details
#==(other) ⇒ Object
21 22 23 |
# File 'lib/hackle/internal/config/parameter_config.rb', line 21 def ==(other) other.is_a?(self.class) && other.parameters == parameters end |
#get(key, default_value = nil) ⇒ Object?
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/hackle/internal/config/parameter_config.rb', line 32 def get(key, default_value = nil) parameter_value = parameters.fetch(key, default_value) return default_value if parameter_value.nil? return parameter_value if default_value.nil? case default_value when String parameter_value.is_a?(String) ? parameter_value : default_value when Numeric parameter_value.is_a?(Numeric) ? parameter_value : default_value when TrueClass, FalseClass parameter_value.is_a?(TrueClass) || parameter_value.is_a?(FalseClass) ? parameter_value : default_value else default_value end end |
#to_s ⇒ Object
25 26 27 |
# File 'lib/hackle/internal/config/parameter_config.rb', line 25 def to_s "Hackle::ParameterConfig(#{parameters})" end |