Class: Onoma::Migration::Actions::NomenclatureCreation

Inherits:
Base
  • Object
show all
Defined in:
lib/onoma/migration/actions/nomenclature_creation.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

action_name, #action_name

Constructor Details

#initialize(element) ⇒ NomenclatureCreation

Returns a new instance of NomenclatureCreation.



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/onoma/migration/actions/nomenclature_creation.rb', line 7

def initialize(element)
  @nomenclature = if element.key?('nomenclature')
                    element['nomenclature'].to_s
                  elsif element.key?('name')
                    element['name'].to_s
                  else
                    nil
                  end
  raise 'No given name' unless @nomenclature

  @options = {}
  notions = element.attr('notions').to_s.split(/\s*\,\s*/).map(&:to_sym)
  @options[:notions] = notions if notions.any?
  @options[:translateable] = element.attr('translateable').to_s != 'false'
end

Instance Attribute Details

#nomenclatureObject (readonly) Also known as: name

Returns the value of attribute nomenclature.



5
6
7
# File 'lib/onoma/migration/actions/nomenclature_creation.rb', line 5

def nomenclature
  @nomenclature
end

#optionsObject (readonly)

Returns the value of attribute options.



5
6
7
# File 'lib/onoma/migration/actions/nomenclature_creation.rb', line 5

def options
  @options
end

Instance Method Details

#human_nameObject



25
26
27
# File 'lib/onoma/migration/actions/nomenclature_creation.rb', line 25

def human_name
  "Create nomenclature #{@name}"
end