Class: Onoma::Migration::Actions::PropertyChange

Inherits:
Base
  • Object
show all
Defined in:
lib/onoma/migration/actions/property_change.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

action_name, #action_name

Constructor Details

#initialize(element) ⇒ PropertyChange

Returns a new instance of PropertyChange.



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/onoma/migration/actions/property_change.rb', line 6

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

Instance Attribute Details

#changesObject (readonly)

Returns the value of attribute changes.



5
6
7
# File 'lib/onoma/migration/actions/property_change.rb', line 5

def changes
  @changes
end

#nameObject (readonly)

Returns the value of attribute name.



5
6
7
# File 'lib/onoma/migration/actions/property_change.rb', line 5

def name
  @name
end

#nomenclatureObject (readonly)

Returns the value of attribute nomenclature.



5
6
7
# File 'lib/onoma/migration/actions/property_change.rb', line 5

def nomenclature
  @nomenclature
end