Class: Accession::Service

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Validations
Defined in:
lib/accession/accession/service.rb

Overview

Provide all of the configuration relating to the type of accessioning. Used by Accession::Request to send to the correct service.

Constant Summary collapse

PROVIDERS =
{ 'managed' => :EGA, 'open' => :ENA }

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(study_type = nil) ⇒ Service

Returns a new instance of Service


13
14
15
# File 'lib/accession/accession/service.rb', line 13

def initialize(study_type = nil)
  @provider = PROVIDERS[study_type]
end

Instance Attribute Details

#providerObject (readonly)

Returns the value of attribute provider


9
10
11
# File 'lib/accession/accession/service.rb', line 9

def provider
  @provider
end

Instance Method Details

#brokerObject


29
30
31
# File 'lib/accession/accession/service.rb', line 29

def broker
  ega? ? provider.to_s : ''
end

#ega?Boolean

Returns:

  • (Boolean)

21
22
23
# File 'lib/accession/accession/service.rb', line 21

def ega?
  provider == :EGA
end

#ena?Boolean

Returns:

  • (Boolean)

17
18
19
# File 'lib/accession/accession/service.rb', line 17

def ena?
  provider == :ENA
end

#loginObject


37
38
39
40
# File 'lib/accession/accession/service.rb', line 37

def 
  return configatron.accession.ega!.to_hash if ega?
  return configatron.accession.ena!.to_hash if ena?
end

#urlObject


33
34
35
# File 'lib/accession/accession/service.rb', line 33

def url
  configatron.accession.url! if valid?
end

#visibilityObject


25
26
27
# File 'lib/accession/accession/service.rb', line 25

def visibility
  ena? ? 'HOLD' : 'PROTECT'
end