Class: Migrate::Migration

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ Migration



23
24
25
26
# File 'lib/migrate/migration.rb', line 23

def initialize(path)
  @path = path
  @name = path.relative_path
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



28
29
30
# File 'lib/migrate/migration.rb', line 28

def name
  @name
end

Instance Method Details

#<=>(other) ⇒ Object



42
43
44
# File 'lib/migrate/migration.rb', line 42

def <=> other
  @name <=> other.name
end

#call(controller) ⇒ Object



30
31
32
# File 'lib/migrate/migration.rb', line 30

def call(controller)
  self.instance_eval(::File.read(@path), @path)
end

#migrate(target, using:, &block) ⇒ Object



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

def migrate(target, using:, &block)
  using.migrate(self.name, target, &block)
end

#to_sObject



38
39
40
# File 'lib/migrate/migration.rb', line 38

def to_s
  @name
end