class ActiveGroonga::Migration
Attributes
path[R]
version[R]
Public Class Methods
inherited(sub_class)
click to toggle source
Calls superclass method
# File lib/active_groonga/migration.rb, line 20 def inherited(sub_class) super @@migrations << sub_class end
migration_name()
click to toggle source
# File lib/active_groonga/migration.rb, line 29 def migration_name name.split(/::/).last end
migrations()
click to toggle source
# File lib/active_groonga/migration.rb, line 25 def migrations @@migrations end
new(version, path, schema)
click to toggle source
# File lib/active_groonga/migration.rb, line 35 def initialize(version, path, schema) @version = version @path = path @schema = schema end
Public Instance Methods
migrate(direction)
click to toggle source
# File lib/active_groonga/migration.rb, line 45 def migrate(direction) result = nil case direction when :up report("migrating") when :down report("reverting") end time = Benchmark.measure do result = send(direction) end case direction when :up report("migrated (%.4fs)" % time.real) when :down report("reverted (%.4fs)" % time.real) end result end
name()
click to toggle source
# File lib/active_groonga/migration.rb, line 41 def name self.class.migration_name end
Private Instance Methods
method_missing(name, *args, &block)
click to toggle source
Calls superclass method
# File lib/active_groonga/migration.rb, line 83 def method_missing(name, *args, &block) if @schema.respond_to?(name) @schema.send(name, *args, &block) else super end end
report(message)
click to toggle source
# File lib/active_groonga/migration.rb, line 66 def report(message) relative_path = @path.relative_path_from(root_directory) text = "#{@version} #{name} (#{relative_path}): #{message}" rest_length = [0, 75 - text.length].max puts("== #{text} #{'=' * rest_length}") end
root_directory()
click to toggle source
# File lib/active_groonga/migration.rb, line 73 def root_directory if defined?(Rails) Rails.root elsif defined?(Padrino) Padrino.root else Pathname.pwd end end