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 }.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(study_type = nil) ⇒ Service

Returns a new instance of Service.



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

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

Instance Attribute Details

#providerObject (readonly)

Returns the value of attribute provider.



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

def provider
  @provider
end

Instance Method Details

#brokerObject



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

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

#ega?Boolean

Returns:

  • (Boolean)


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

def ega?
  provider == :EGA
end

#ena?Boolean

Returns:

  • (Boolean)


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

def ena?
  provider == :ENA
end

#loginObject



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

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

#urlObject



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

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

#visibilityObject



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

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