class Onoma::Migration::Actions::PropertyCreation
Attributes
name[R]
nomenclature[R]
options[R]
type[R]
Public Class Methods
new(element)
click to toggle source
# File lib/onoma/migration/actions/property_creation.rb, line 6 def initialize(element) name = element['property'].split('.') @nomenclature = name.first @name = name.second @type = element['type'].to_sym unless Onoma::PROPERTY_TYPES.include?(@type) raise ArgumentError.new("Property #{name} type is unknown: #{@type.inspect}") end @options = {} if element.has_attribute?('fallbacks') @options[:fallbacks] = element.attr('fallbacks').to_s.strip.split(/[[:space:]]*\,[[:space:]]*/).map(&:to_sym) end if element.has_attribute?('default') @options[:default] = element.attr('default').to_sym end @options[:required] = element.attr('required').to_s == 'true' # @options[:inherit] = !!(element.attr('inherit').to_s == 'true') if element.has_attribute?('choices') if type == :choice || type == :choice_list @options[:choices] = element.attr('choices').to_s.strip.split(/[[:space:]]*\,[[:space:]]*/).map(&:to_sym) elsif type == :item || type == :item_list @options[:choices] = element.attr('choices').to_s.strip.to_sym end end end
Public Instance Methods
human_name()
click to toggle source
# File lib/onoma/migration/actions/property_creation.rb, line 33 def human_name updates = [] updates << "#{@name} as name" @options.each do |k, v| updates << "#{v} as #{k}" end sentence = "Create property #{@nomenclature}.#{@name} with " + updates.to_sentence end