Class: ActiveGroonga::Migration
- Inherits:
-
Object
- Object
- ActiveGroonga::Migration
show all
- Defined in:
- lib/active_groonga/migration.rb
Constant Summary
collapse
- @@migrations =
[]
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(version, path, schema) ⇒ Migration
Returns a new instance of Migration.
35
36
37
38
39
|
# File 'lib/active_groonga/migration.rb', line 35
def initialize(version, path, schema)
@version = version
@path = path
@schema = schema
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, &block) ⇒ Object
73
74
75
76
77
78
79
|
# File 'lib/active_groonga/migration.rb', line 73
def method_missing(name, *args, &block)
if @schema.respond_to?(name)
@schema.send(name, *args, &block)
else
super
end
end
|
Instance Attribute Details
#path ⇒ Object
Returns the value of attribute path.
34
35
36
|
# File 'lib/active_groonga/migration.rb', line 34
def path
@path
end
|
#version ⇒ Object
Returns the value of attribute version.
34
35
36
|
# File 'lib/active_groonga/migration.rb', line 34
def version
@version
end
|
Class Method Details
.inherited(sub_class) ⇒ Object
20
21
22
23
|
# File 'lib/active_groonga/migration.rb', line 20
def inherited(sub_class)
super
@@migrations << sub_class
end
|
.migration_name ⇒ Object
29
30
31
|
# File 'lib/active_groonga/migration.rb', line 29
def migration_name
name.split(/::/).last
end
|
.migrations ⇒ Object
25
26
27
|
# File 'lib/active_groonga/migration.rb', line 25
def migrations
@@migrations
end
|
Instance Method Details
#migrate(direction) ⇒ Object
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
# 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 ⇒ Object
41
42
43
|
# File 'lib/active_groonga/migration.rb', line 41
def name
self.class.migration_name
end
|