Class Index [+]

Quicksearch

Sequel::MigrationReverser

Handles the reversing of reversible migrations. Basically records supported methods calls, translates them to reversed calls, and returns them in reverse order.

Public Class Methods

new() click to toggle source
     # File lib/sequel/extensions/migration.rb, line 149
149:     def initialize
150:       @actions = []
151:     end

Public Instance Methods

reverse(&block) click to toggle source

Reverse the actions for the given block. Takes the block given and returns a new block that reverses the actions taken by the given block.

     # File lib/sequel/extensions/migration.rb, line 156
156:     def reverse(&block)
157:       begin
158:         instance_eval(&block)
159:       rescue
160:         just_raise = true
161:       end
162:       if just_raise
163:         Proc.new{raise Sequel::Error, 'irreversible migration method used, you may need to write your own down method'}
164:       else
165:         actions = @actions.reverse
166:         Proc.new do
167:           actions.each do |a|
168:             if a.last.is_a?(Proc)
169:               pr = a.pop
170:               send(*a, &pr)
171:             else
172:               send(*a)
173:             end
174:           end
175:         end
176:       end
177:     end

Private Instance Methods

add_column(*args) click to toggle source
     # File lib/sequel/extensions/migration.rb, line 181
181:     def add_column(*args)
182:       @actions << [:drop_column, args[0], args[1]]
183:     end
add_index(*args) click to toggle source
     # File lib/sequel/extensions/migration.rb, line 185
185:     def add_index(*args)
186:       @actions << [:drop_index, *args]
187:     end
alter_table(table, &block) click to toggle source
     # File lib/sequel/extensions/migration.rb, line 189
189:     def alter_table(table, &block)
190:       @actions << [:alter_table, table, MigrationAlterTableReverser.new.reverse(&block)]
191:     end
create_join_table(*args) click to toggle source
     # File lib/sequel/extensions/migration.rb, line 193
193:     def create_join_table(*args)
194:       @actions << [:drop_join_table, *args]
195:     end
create_table(*args) click to toggle source
     # File lib/sequel/extensions/migration.rb, line 197
197:     def create_table(*args)
198:       @actions << [:drop_table, args.first]
199:     end
create_view(*args) click to toggle source
     # File lib/sequel/extensions/migration.rb, line 201
201:     def create_view(*args)
202:       @actions << [:drop_view, args.first]
203:     end
rename_column(table, name, new_name) click to toggle source
     # File lib/sequel/extensions/migration.rb, line 205
205:     def rename_column(table, name, new_name)
206:       @actions << [:rename_column, table, new_name, name]
207:     end
rename_table(table, new_name) click to toggle source
     # File lib/sequel/extensions/migration.rb, line 209
209:     def rename_table(table, new_name)
210:       @actions << [:rename_table, new_name, table]
211:     end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.