Class: Onoma::Migration::Actions::ItemChange
- Defined in:
- lib/onoma/migration/actions/item_change.rb
Instance Attribute Summary collapse
-
#changes ⇒ Object
readonly
Returns the value of attribute changes.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#nomenclature ⇒ Object
readonly
Returns the value of attribute nomenclature.
Instance Method Summary collapse
- #human_name ⇒ Object
-
#initialize(element) ⇒ ItemChange
constructor
A new instance of ItemChange.
- #new_name ⇒ Object
- #new_name? ⇒ Boolean
Methods inherited from Base
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
#changes ⇒ Object (readonly)
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 (readonly)
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 (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_name ⇒ Object
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_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 |