Class: XMigra::RevertFile
Constant Summary collapse
- REVERSION_SUBDIR =
'rollback'
Instance Attribute Summary collapse
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #exist? ⇒ Boolean
-
#initialize(migration) ⇒ RevertFile
constructor
A new instance of RevertFile.
- #inspect ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(migration) ⇒ RevertFile
Returns a new instance of RevertFile.
7 8 9 10 11 12 13 14 15 |
# File 'lib/xmigra/revert_file.rb', line 7 def initialize(migration) @migration = migration mig_path = Pathname(migration.file_path) @description = "REVERT #{migration.description} (#{mig_path.basename})" @path = migration.schema_dir.join( REVERSION_SUBDIR, mig_path.basename.to_s.sub(/\..*?$/, '.sql') ) end |
Instance Attribute Details
#description ⇒ Object (readonly)
Returns the value of attribute description.
17 18 19 |
# File 'lib/xmigra/revert_file.rb', line 17 def description @description end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
17 18 19 |
# File 'lib/xmigra/revert_file.rb', line 17 def path @path end |
Instance Method Details
#exist? ⇒ Boolean
38 39 40 |
# File 'lib/xmigra/revert_file.rb', line 38 def exist? @path.exist? end |
#inspect ⇒ Object
31 32 33 34 35 36 |
# File 'lib/xmigra/revert_file.rb', line 31 def inspect "#<#{self.class.name} %s%s>" % [ @path, (" (missing)" unless @path.exist?), ] end |
#to_s ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/xmigra/revert_file.rb', line 19 def to_s if @path.exist? @sql ||= "-- %s:\n\n%s\n%s" % [ @description, @path.read, @migration.reversion_tracking_sql ] else "-- #@description: No reversion given\n" end end |