Class: InstrumentLoader

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
app/services/instrument_loader.rb

Overview

Singleton template class for loading either CSV or json instruments

Direct Known Subclasses

InstrumentLoaderCsv, InstrumentLoaderJson

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#instrumentObject (readonly)

Returns the value of attribute instrument


8
9
10
# File 'app/services/instrument_loader.rb', line 8

def instrument
  @instrument
end

Instance Method Details

#load(instrument:, type: :json) ⇒ Object

load method saves an instrument to DB from either CSV or json


11
12
13
14
15
16
17
18
# File 'app/services/instrument_loader.rb', line 11

def load(instrument:, type: :json)
  raise I18n.t :loader_nil_instrument unless instrument 
 
  @instrument = instrument
  # A json instrument will have its json representation stored in content 
  load!(type: type)
  instrument
end