Class: Turntables::Transaction
- Inherits:
-
Object
- Object
- Turntables::Transaction
- Defined in:
- lib/turntables/transaction.rb
Overview
This class takes care of a single transaction
Instance Attribute Summary collapse
-
#comment ⇒ Object
The comment should be parsed out from the respective sql file.
-
#data ⇒ Object
The sql information to be passed on to the db registry.
-
#version ⇒ Object
The version should be obtained from the file name of the respective sql file.
Instance Method Summary collapse
-
#initialize(sql_file_contents, filename) ⇒ Transaction
constructor
Initialize this object with the contents of the sql file.
Constructor Details
#initialize(sql_file_contents, filename) ⇒ Transaction
Initialize this object with the contents of the sql file
11 12 13 14 15 16 17 |
# File 'lib/turntables/transaction.rb', line 11 def initialize(sql_file_contents,filename) # Select only the lines that begin with '--$' @comment = sql_file_contents.lines.select{|el| el.match(/--\$/)}.join @comment.gsub!(/--\$/, '') @version = filename.to_i @data = sql_file_contents end |
Instance Attribute Details
#comment ⇒ Object
The comment should be parsed out from the respective sql file. We want to keep the comments in the sql file to keep things organized. We do not want to alter the sql language to fit our needs. Therefore we just require the user to comment lines as ‘–$ my comment here’ in order to parse them out
34 35 36 |
# File 'lib/turntables/transaction.rb', line 34 def comment @comment end |
#data ⇒ Object
The sql information to be passed on to the db registry
37 38 39 |
# File 'lib/turntables/transaction.rb', line 37 def data @data end |
#version ⇒ Object
The version should be obtained from the file name of the respective sql file.
21 22 23 |
# File 'lib/turntables/transaction.rb', line 21 def version @version end |