Class: Etna::Cwl::StrictMapLoader
Instance Method Summary collapse
-
#initialize(items, keys) ⇒ StrictMapLoader
constructor
A new instance of StrictMapLoader.
- #load(val) ⇒ Object
Methods inherited from Loader
#as_array, #as_mapped_array, #map, #optional, #or
Constructor Details
#initialize(items, keys) ⇒ StrictMapLoader
Returns a new instance of StrictMapLoader.
145 146 147 148 |
# File 'lib/etna/cwl.rb', line 145 def initialize(items, keys) @items = items @keys = keys end |
Instance Method Details
#load(val) ⇒ Object
150 151 152 153 154 155 156 157 158 |
# File 'lib/etna/cwl.rb', line 150 def load(val) if val.is_a?(Hash) val.map do |k, v| [@keys.load(k), @items.load(v)] end.to_h else raise "Unexpected val #{val.inspect} for hash" end end |