Class: Etna::Cwl::UnionLoader

Inherits:
Loader
  • Object
show all
Defined in:
lib/etna/cwl.rb

Instance Method Summary collapse

Methods inherited from Loader

#as_array, #as_mapped_array, #map, #optional, #or

Constructor Details

#initialize(*alternatives) ⇒ UnionLoader

Returns a new instance of UnionLoader.



302
303
304
# File 'lib/etna/cwl.rb', line 302

def initialize(*alternatives)
  @alternatives = alternatives
end

Instance Method Details

#load(val) ⇒ Object



306
307
308
309
310
311
312
313
314
315
316
317
# File 'lib/etna/cwl.rb', line 306

def load(val)
  errors = []
  @alternatives.each do |loader|
    begin
      return loader.load(val)
    rescue => e
      errors << e.to_s
    end
  end

  raise errors.join(", ")
end