Class: Fresco::MigrationBuilder
- Inherits:
-
Object
- Object
- Fresco::MigrationBuilder
- Defined in:
- lib/fresco/migration_builder.rb
Instance Attribute Summary collapse
-
#down_sql ⇒ Object
readonly
Returns the value of attribute down_sql.
-
#up_sql ⇒ Object
readonly
Returns the value of attribute up_sql.
Instance Method Summary collapse
- #down(&blk) ⇒ Object
-
#initialize ⇒ MigrationBuilder
constructor
A new instance of MigrationBuilder.
- #sql(stmt) ⇒ Object
- #up(&blk) ⇒ Object
Constructor Details
#initialize ⇒ MigrationBuilder
Returns a new instance of MigrationBuilder.
33 34 35 36 37 |
# File 'lib/fresco/migration_builder.rb', line 33 def initialize @up_sql = [] @down_sql = [] @current = nil end |
Instance Attribute Details
#down_sql ⇒ Object (readonly)
Returns the value of attribute down_sql.
31 32 33 |
# File 'lib/fresco/migration_builder.rb', line 31 def down_sql @down_sql end |
#up_sql ⇒ Object (readonly)
Returns the value of attribute up_sql.
31 32 33 |
# File 'lib/fresco/migration_builder.rb', line 31 def up_sql @up_sql end |
Instance Method Details
#down(&blk) ⇒ Object
45 46 47 48 49 |
# File 'lib/fresco/migration_builder.rb', line 45 def down(&blk) @current = @down_sql instance_eval(&blk) if blk @current = nil end |
#sql(stmt) ⇒ Object
51 52 53 54 |
# File 'lib/fresco/migration_builder.rb', line 51 def sql(stmt) abort "[build] `sql` called outside `up` / `down` block" if @current.nil? @current << stmt end |
#up(&blk) ⇒ Object
39 40 41 42 43 |
# File 'lib/fresco/migration_builder.rb', line 39 def up(&blk) @current = @up_sql instance_eval(&blk) if blk @current = nil end |