Class: Migr8::Migration
- Inherits:
-
Object
- Object
- Migr8::Migration
- Defined in:
- lib/migr8.rb
Instance Attribute Summary collapse
-
#applied_at ⇒ Object
Returns the value of attribute applied_at.
-
#author ⇒ Object
Returns the value of attribute author.
-
#desc ⇒ Object
Returns the value of attribute desc.
-
#down ⇒ Object
Returns the value of attribute down.
-
#down_script ⇒ Object
Returns the value of attribute down_script.
-
#id ⇒ Object
Returns the value of attribute id.
-
#up ⇒ Object
Returns the value of attribute up.
-
#up_script ⇒ Object
Returns the value of attribute up_script.
-
#vars ⇒ Object
Returns the value of attribute vars.
-
#version ⇒ Object
Returns the value of attribute version.
Class Method Summary collapse
Instance Method Summary collapse
- #applied? ⇒ Boolean
- #applied_at_or(default) ⇒ Object
- #filepath ⇒ Object
-
#initialize(version = nil, author = nil, desc = nil) ⇒ Migration
constructor
A new instance of Migration.
Constructor Details
#initialize(version = nil, author = nil, desc = nil) ⇒ Migration
Returns a new instance of Migration.
56 57 58 59 60 61 62 63 64 |
# File 'lib/migr8.rb', line 56 def initialize(version=nil, =nil, desc=nil) #; [!y4dy3] takes version, author, and desc arguments. @version = version @author = @desc = desc @vars = {} @up = '' @down = '' end |
Instance Attribute Details
#applied_at ⇒ Object
Returns the value of attribute applied_at.
54 55 56 |
# File 'lib/migr8.rb', line 54 def applied_at @applied_at end |
#author ⇒ Object
Returns the value of attribute author.
53 54 55 |
# File 'lib/migr8.rb', line 53 def @author end |
#desc ⇒ Object
Returns the value of attribute desc.
53 54 55 |
# File 'lib/migr8.rb', line 53 def desc @desc end |
#down ⇒ Object
Returns the value of attribute down.
53 54 55 |
# File 'lib/migr8.rb', line 53 def down @down end |
#down_script ⇒ Object
Returns the value of attribute down_script.
54 55 56 |
# File 'lib/migr8.rb', line 54 def down_script @down_script end |
#id ⇒ Object
Returns the value of attribute id.
54 55 56 |
# File 'lib/migr8.rb', line 54 def id @id end |
#up ⇒ Object
Returns the value of attribute up.
53 54 55 |
# File 'lib/migr8.rb', line 53 def up @up end |
#up_script ⇒ Object
Returns the value of attribute up_script.
54 55 56 |
# File 'lib/migr8.rb', line 54 def up_script @up_script end |
#vars ⇒ Object
Returns the value of attribute vars.
53 54 55 |
# File 'lib/migr8.rb', line 53 def vars @vars end |
#version ⇒ Object
Returns the value of attribute version.
53 54 55 |
# File 'lib/migr8.rb', line 53 def version @version end |
Class Method Details
.load_from(filepath) ⇒ Object
113 114 115 116 117 118 119 120 121 122 123 |
# File 'lib/migr8.rb', line 113 def self.load_from(filepath) #; [!fbea5] loads data from file and returns migration object. data = File.open(filepath) {|f| YAML.load(f) } mig = self.new(data['version'], data['author'], data['desc']) #; [!sv21s] expands values of 'vars'. mig.vars = Util::Expander.(data['vars']) #; [!32ns3] not expand both 'up' and 'down'. mig.up = data['up'] mig.down = data['down'] return mig end |
Instance Method Details
#applied? ⇒ Boolean
66 67 68 69 |
# File 'lib/migr8.rb', line 66 def applied? #; [!ebzct] returns false when @applied_at is nil, else true. return ! @applied_at.nil? end |
#applied_at_or(default) ⇒ Object
99 100 101 102 103 104 |
# File 'lib/migr8.rb', line 99 def applied_at_or(default) #; [!zazux] returns default arugment when not applied. return default unless applied? #; [!fxb4y] returns @applied_at without msec. return @applied_at.split(/\./)[0] # '12:34:56.789' -> '12:34:56' end |
#filepath ⇒ Object
106 107 108 109 110 111 |
# File 'lib/migr8.rb', line 106 def filepath #; [!l9t5k] returns nil when version is not set. return nil unless @version #; [!p0d9q] returns filepath of migration file. return Repository.new(nil).migration_filepath(@version) end |