Class: Insdc::Country

Inherits:
ApplicationRecord show all
Includes:
SharedBehaviour::Named
Defined in:
app/models/insdc/country.rb

Overview

Note:

be aware you may need to escape the square brackets if using zsh

Provides a controlled vocabulary describing names of countries or oceans/seas in accordance with the INSDC (www.insdc.org/)

In addition the list may contain non-geographic identifiers that are permitted by the EBI sample checklists (eg ‘not collected’) An example EBI checklist may be found here: www.ebi.ac.uk/ena/browser/view/ERC000011

The list can be populated via the rake:task bundle exec rake insdc:countries:import

To import from an alternative sample sheet, use bundle exec rake insdc:countries:import[other_accession]

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from SharedBehaviour::Named

included

Methods inherited from ApplicationRecord

alias_association, convert_labware_to_receptacle_for, find_by_id_or_name, find_by_id_or_name!

Methods included from Squishify

extended

Instance Attribute Details

#:name(: name) ⇒ String

Returns The name of the country, ocean, sea or permitted non-geographic region.

Returns:

  • (String)

    The name of the country, ocean, sea or permitted non-geographic region



22
# File 'app/models/insdc/country.rb', line 22

attribute :name, :string

#:sort_priority(: sort_priority) ⇒ Integer

Higher sort priorities are sorted towards the top of dropdown lists to aid picking

Returns:

  • (Integer)

    The priority of the region



27
# File 'app/models/insdc/country.rb', line 27

attribute :sort_priority, :integer, default: 0

#:validation_state(: validation_state) ⇒ Symbol

Note:

This has been implemented as an enum for flexible extension at a later date.

Indicates if a region is valid for selection or not

Returns:

  • (Symbol)

    :valid or :invalid



33
# File 'app/models/insdc/country.rb', line 33

enum :validation_state, { valid: 0, invalid: 1 }, suffix: :state

Class Method Details

.optionsObject



47
48
49
# File 'app/models/insdc/country.rb', line 47

def self.options
  sorted_for_select.pluck(:name)
end

Instance Method Details

#invalid!Object



51
52
53
# File 'app/models/insdc/country.rb', line 51

def invalid!
  update!(validation_state: :invalid)
end