Class: Prefab::ConfigValueUnwrapper
- Inherits:
-
Object
- Object
- Prefab::ConfigValueUnwrapper
- Defined in:
- lib/prefab/config_value_unwrapper.rb
Instance Attribute Summary collapse
-
#value ⇒ Object
readonly
Returns the value of attribute value.
-
#weighted_value_index ⇒ Object
readonly
Returns the value of attribute weighted_value_index.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(value, weighted_value_index = nil) ⇒ ConfigValueUnwrapper
constructor
A new instance of ConfigValueUnwrapper.
- #unwrap ⇒ Object
Constructor Details
#initialize(value, weighted_value_index = nil) ⇒ ConfigValueUnwrapper
Returns a new instance of ConfigValueUnwrapper.
7 8 9 10 |
# File 'lib/prefab/config_value_unwrapper.rb', line 7 def initialize(value, weighted_value_index = nil) @value = value @weighted_value_index = weighted_value_index end |
Instance Attribute Details
#value ⇒ Object (readonly)
Returns the value of attribute value.
5 6 7 |
# File 'lib/prefab/config_value_unwrapper.rb', line 5 def value @value end |
#weighted_value_index ⇒ Object (readonly)
Returns the value of attribute weighted_value_index.
5 6 7 |
# File 'lib/prefab/config_value_unwrapper.rb', line 5 def weighted_value_index @weighted_value_index end |
Class Method Details
.deepest_value(config_value, config_key, context) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/prefab/config_value_unwrapper.rb', line 23 def self.deepest_value(config_value, config_key, context) if config_value&.type == :weighted_values value, index = Prefab::WeightedValueResolver.new( config_value.weighted_values.weighted_values, config_key, context.get(config_value.weighted_values.hash_by_property_name) ).resolve new(deepest_value(value.value, config_key, context).value, index) else new(config_value) end end |
Instance Method Details
#unwrap ⇒ Object
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/prefab/config_value_unwrapper.rb', line 12 def unwrap case value.type when :int, :string, :double, :bool, :log_level value.public_send(value.type) when :string_list value.string_list.values else raise "Unknown type: #{config_value.type}" end end |