Class: Monark::Migration
- Inherits:
-
Object
- Object
- Monark::Migration
- Defined in:
- lib/monark/migration.rb
Overview
A Monark migration. Acceptable formats are ‘.sql`, `.sql.erb` and `.rb`.
Instance Attribute Summary collapse
-
#kind ⇒ Object
Returns the value of attribute kind.
-
#path ⇒ Object
Returns the value of attribute path.
-
#reloadable ⇒ Object
(also: #reloadable?)
Returns the value of attribute reloadable.
-
#root ⇒ Object
Returns the value of attribute root.
Instance Method Summary collapse
- #code ⇒ Object
-
#initialize(root, path, proc = nil) ⇒ Migration
constructor
A new instance of Migration.
- #perform ⇒ Object
Constructor Details
Instance Attribute Details
#kind ⇒ Object
Returns the value of attribute kind.
6 7 8 |
# File 'lib/monark/migration.rb', line 6 def kind @kind end |
#path ⇒ Object
Returns the value of attribute path.
6 7 8 |
# File 'lib/monark/migration.rb', line 6 def path @path end |
#reloadable ⇒ Object Also known as: reloadable?
Returns the value of attribute reloadable.
6 7 8 |
# File 'lib/monark/migration.rb', line 6 def reloadable @reloadable end |
#root ⇒ Object
Returns the value of attribute root.
6 7 8 |
# File 'lib/monark/migration.rb', line 6 def root @root end |
Instance Method Details
#code ⇒ Object
15 16 17 |
# File 'lib/monark/migration.rb', line 15 def code @code ||= load_file("sql", "sql.erb", "rb") end |
#perform ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/monark/migration.rb', line 19 def perform code if !kind puts "-> calling '#{@path}'" @code.call elsif @kind == "rb" puts "-> evaluating '#{@path}'" binding.eval(@code, path, 0) else puts "-> executing '#{@path}'" ActiveRecord::Base.connection.execute @code end end |