Class: PgAssistant::Definitions::Base
- Inherits:
-
Object
- Object
- PgAssistant::Definitions::Base
- Defined in:
- lib/pg_assistant/definitions/base.rb
Direct Known Subclasses
Class Attribute Summary collapse
-
.directory_path ⇒ Object
Returns the value of attribute directory_path.
Instance Method Summary collapse
- #filename ⇒ Object
- #full_path ⇒ Object
-
#initialize(name, version) ⇒ Base
constructor
A new instance of Base.
- #path ⇒ Object
- #to_sql ⇒ Object
- #version ⇒ Object
Constructor Details
#initialize(name, version) ⇒ Base
Returns a new instance of Base.
12 13 14 15 |
# File 'lib/pg_assistant/definitions/base.rb', line 12 def initialize(name, version) @name = name @version = version.to_i end |
Class Attribute Details
.directory_path ⇒ Object
Returns the value of attribute directory_path.
5 6 7 |
# File 'lib/pg_assistant/definitions/base.rb', line 5 def directory_path @directory_path end |
Instance Method Details
#filename ⇒ Object
33 34 35 |
# File 'lib/pg_assistant/definitions/base.rb', line 33 def filename "#{@name}_v#{version}.sql" end |
#full_path ⇒ Object
21 22 23 |
# File 'lib/pg_assistant/definitions/base.rb', line 21 def full_path Rails.root.join(path) end |
#path ⇒ Object
25 26 27 |
# File 'lib/pg_assistant/definitions/base.rb', line 25 def path self.class.directory_path.join(filename) end |
#to_sql ⇒ Object
17 18 19 |
# File 'lib/pg_assistant/definitions/base.rb', line 17 def to_sql File.read(full_path) end |
#version ⇒ Object
29 30 31 |
# File 'lib/pg_assistant/definitions/base.rb', line 29 def version @version.to_s.rjust(2, "0") end |