Class: Onoma::Migration::Actions::ItemChange
- Inherits:
-
Base
- Object
- Base
- Onoma::Migration::Actions::ItemChange
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
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 do |k, _v|
%w[item].include?(k)
end.each_with_object({}) do |(k, v), h|
h[k.to_sym] = (v.to_s.blank? ? nil : v.to_s)
end
end
|
Instance Attribute Details
#changes ⇒ Object
Returns the value of attribute changes.
5
6
7
|
# File 'lib/onoma/migration/actions/item_change.rb', line 5
def changes
@changes
end
|
#name ⇒ Object
Returns the value of attribute name.
5
6
7
|
# File 'lib/onoma/migration/actions/item_change.rb', line 5
def name
@name
end
|
#nomenclature ⇒ Object
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_name ⇒ Object
29
30
31
|
# File 'lib/onoma/migration/actions/item_change.rb', line 29
def human_name
"Change item #{@nomenclature}##{@name} with " + changes.inspect
end
|
#label ⇒ Object
25
26
27
|
# File 'lib/onoma/migration/actions/item_change.rb', line 25
def label
"change_item #{@nomenclature}##{@name}(" + changes.simple_print + ')'
end
|
#new_name ⇒ Object
21
22
23
|
# File 'lib/onoma/migration/actions/item_change.rb', line 21
def new_name
@changes[:name]
end
|
#new_name? ⇒ Boolean
17
18
19
|
# File 'lib/onoma/migration/actions/item_change.rb', line 17
def new_name?
@changes[:name].present?
end
|