Sha256: 7608f2da164f6742ba8176af8a58d436828768c73bc2ac74c24b991472dc8fd8

Contents?: true

Size: 1.36 KB

Versions: 14

Compression:

Stored size: 1.36 KB

Contents

module Onoma
  module Migration
    module Actions
      class PropertyChange < Onoma::Migration::Actions::Base
        attr_reader :nomenclature, :name, :changes
        def initialize(element)
          name = element['property'].split('.')
          @nomenclature = name.first
          @name = name.second

          @changes = {}
          if element.has_attribute?('type')
            changes[:type] = element.attr('type').to_sym
          end
          if element.has_attribute?('fallbacks')
            @changes[:fallbacks] = element.attr('fallbacks').to_s.strip.split(/[[:space:]]*\,[[:space:]]*/).map(&:to_sym)
          end
          if element.has_attribute?('default')
            @changes[:default] = element.attr('default').to_sym
          end
          if element.has_attribute?('required')
            @changes[:required] = element.attr('required').to_s == 'true'
          end
          # @changes[:inherit]  = !!(element.attr('inherit').to_s == 'true')
          if element.has_attribute?('choices')
            if type == :choice || type == :choice_list
              @changes[:choices] = element.attr('choices').to_s.strip.split(/[[:space:]]*\,[[:space:]]*/).map(&:to_sym)
            elsif type == :item || type == :item_list
              @changes[:choices] = element.attr('choices').to_s.strip.to_sym
            end
          end
        end
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
onoma-0.9.3 lib/onoma/migration/actions/property_change.rb
onoma-0.9.2 lib/onoma/migration/actions/property_change.rb
onoma-0.9.1 lib/onoma/migration/actions/property_change.rb
onoma-0.9.0 lib/onoma/migration/actions/property_change.rb
onoma-0.8.9 lib/onoma/migration/actions/property_change.rb
onoma-0.8.8 lib/onoma/migration/actions/property_change.rb
onoma-0.8.7 lib/onoma/migration/actions/property_change.rb
onoma-0.8.6 lib/onoma/migration/actions/property_change.rb
onoma-0.8.5 lib/onoma/migration/actions/property_change.rb
onoma-0.8.4 lib/onoma/migration/actions/property_change.rb
onoma-0.8.3 lib/onoma/migration/actions/property_change.rb
onoma-0.8.2 lib/onoma/migration/actions/property_change.rb
onoma-0.8.1 lib/onoma/migration/actions/property_change.rb
onoma-0.8.0 lib/onoma/migration/actions/property_change.rb