Class: Migrations
- Inherits:
-
Object
- Object
- Migrations
- Defined in:
- lib/gourmand.rb
Constant Summary collapse
- Migrations =
[]
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(gourmand) ⇒ Migrations
constructor
A new instance of Migrations.
- #migrate! ⇒ Object
Constructor Details
#initialize(gourmand) ⇒ Migrations
Returns a new instance of Migrations.
231 232 233 |
# File 'lib/gourmand.rb', line 231 def initialize(gourmand) @gourmand = gourmand end |
Class Method Details
.migration(version, &migration) ⇒ Object
235 236 237 |
# File 'lib/gourmand.rb', line 235 def self.migration(version, &migration) Migrations << [Version.new(version), migration] end |
Instance Method Details
#migrate! ⇒ Object
253 254 255 256 257 258 259 260 |
# File 'lib/gourmand.rb', line 253 def migrate! Migrations. sort{|x, y| x[0] <=> y[0]}. reject{|x| (x[0] <= @gourmand.version) || (x[0] > Gourmand.version)}.each{|version, mig| mig.call(@gourmand) } File.open(@gourmand.version_file, "w"){|o| o.puts Gourmand.version} end |