class Onoma::Migration::Base
Attributes
name[R]
number[R]
Public Class Methods
new(number, name, element = nil)
click to toggle source
# File lib/onoma/migration/base.rb, line 17 def initialize(number, name, element = nil) @number = number @name = name @actions = [] if element element.children.each do |child| next unless child.is_a? Nokogiri::XML::Element @actions << "Onoma::Migration::Actions::#{child.name.underscore.classify}".constantize.new(child) end end end
parse(file)
click to toggle source
# File lib/onoma/migration/base.rb, line 4 def self.parse(file) f = File.open(file, 'rb') document = Nokogiri::XML(f) do |config| config.strict.nonet.noblanks.noent end f.close root = document.root number = file.basename.to_s.split('_').first.to_i new(number, root['name'], root) end
Public Instance Methods
each_action(&block)
click to toggle source
# File lib/onoma/migration/base.rb, line 30 def each_action(&block) @actions.each(&block) end
inspect()
click to toggle source
# File lib/onoma/migration/base.rb, line 34 def inspect "#<#{self.class.name}:#{format('%#x', object_id)} ##{number} #{name.inspect} (#{@actions.size} actions)>" end