Class: Onoma::Migration::Actions::ItemChange

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

action_name, #action_name

Constructor Details

#initialize(element) ⇒ ItemChange

Returns a new instance of ItemChange.



6
7
8
9
10
11
12
13
14
15
# File 'lib/onoma/migration/actions/item_change.rb', line 6

def initialize(element)
  name = element['item'].split('#')
  @nomenclature = name.first
  @name = name.second
  @changes = element.attributes
                    .delete_if { |k, _v| %w[item].include?(k) }
                    .each_with_object({}) do |(k, v), h|
                      h[k.to_sym] = (v.to_s.blank? ? nil : v.to_s)
                    end
end

Instance Attribute Details

#changesObject (readonly)

Returns the value of attribute changes.



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

def changes
  @changes
end

#nameObject (readonly)

Returns the value of attribute name.



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

def name
  @name
end

#nomenclatureObject (readonly)

Returns the value of attribute nomenclature.



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

def nomenclature
  @nomenclature
end

Instance Method Details

#human_nameObject



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

def human_name
  "Change item #{@nomenclature}##{@name} with " + changes.inspect
end

#new_nameObject



21
22
23
# File 'lib/onoma/migration/actions/item_change.rb', line 21

def new_name
  @changes[:name]
end

#new_name?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/onoma/migration/actions/item_change.rb', line 17

def new_name?
  @changes[:name].present?
end