class Onoma::Migration::Actions::ItemCreation
Attributes
name[R]
nomenclature[R]
options[R]
Public Class Methods
new(element)
click to toggle source
# File lib/onoma/migration/actions/item_creation.rb, line 6 def initialize(element) raise 'Need item attribute' unless element['item'] name = element['item'].split('#') @nomenclature = name.first @name = name.second @options = element.attributes .delete_if { |k, _v| k =~ /name(:[a-z]{3})?/ || %w[item parent nomenclature].include?(k) } .each_with_object({}) { |(k, v), h| h[k.to_sym] = v.to_s } @options[:parent] = element['parent'].to_sym if element.key?('parent') end
Public Instance Methods
human_name()
click to toggle source
# File lib/onoma/migration/actions/item_creation.rb, line 22 def human_name updates = [] updates << "#{@name} as name" updates << "#{@parent} as parent" if parent? @options.each do |k, v| updates << "#{v} as #{k}" end sentence = "Create item #{@nomenclature}##{@name} with " + updates.to_sentence end
options?()
click to toggle source
# File lib/onoma/migration/actions/item_creation.rb, line 18 def options? @options.any? end