Class: ActiveGroonga::Migration — activegroonga - ラングバ

Class: ActiveGroonga::Migration

Inherits:
Object
  • Object
show all
Defined in:
lib/active_groonga/migration.rb

Constant Summary

@@migrations =
[]

Instance Attribute Summary (collapse)

Class Method Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (Migration) initialize(version, path, schema)

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

- (Object) method_missing(name, *args, &block) (private)



83
84
85
86
87
88
89
# 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

Instance Attribute Details

- (Object) path (readonly)

Returns the value of attribute path



34
35
36
# File 'lib/active_groonga/migration.rb', line 34

def path
  @path
end

- (Object) version (readonly)

Returns the value of attribute version



34
35
36
# File 'lib/active_groonga/migration.rb', line 34

def version
  @version
end

Class Method Details

+ (Object) migration_name



29
30
31
# File 'lib/active_groonga/migration.rb', line 29

def migration_name
  name.split(/::/).last
end

+ (Object) migrations



25
26
27
# File 'lib/active_groonga/migration.rb', line 25

def migrations
  @@migrations
end

Instance Method Details

- (Object) migrate(direction)



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

- (Object) name



41
42
43
# File 'lib/active_groonga/migration.rb', line 41

def name
  self.class.migration_name
end