Sha256: c395bf21486d1f77227dc03ec5b42fff1e2b3fb62914aecd01f97f929849750b

Contents?: true

Size: 797 Bytes

Versions: 5

Compression:

Stored size: 797 Bytes

Contents

module Onoma
  module Migration
    module Actions
      class ItemChange < Onoma::Migration::Actions::Base
        attr_reader :nomenclature, :name, :changes
        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

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

        def new_name
          @changes[:name]
        end

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

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
onoma-0.4.2 lib/onoma/migration/actions/item_change.rb
onoma-0.5.1 lib/onoma/migration/actions/item_change.rb
onoma-0.5.0 lib/onoma/migration/actions/item_change.rb
onoma-0.4.1 lib/onoma/migration/actions/item_change.rb
onoma-0.4.0 lib/onoma/migration/actions/item_change.rb