Class: DatabasePatcher::PatchEntity
- Inherits:
-
Object
- Object
- DatabasePatcher::PatchEntity
- Defined in:
- lib/database_patcher/patch_entity.rb
Defined Under Namespace
Constant Summary collapse
- UUID_MATCHER =
'[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}'.freeze
Instance Attribute Summary collapse
-
#interface ⇒ Object
readonly
Returns the value of attribute interface.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Class Method Summary collapse
Instance Method Summary collapse
- #down(_connection) ⇒ Object
-
#initialize(path, interface) ⇒ PatchEntity
constructor
A new instance of PatchEntity.
- #timestamp ⇒ Object
- #uniq_indentifier ⇒ Object
- #up(_connection) ⇒ Object
- #uuid ⇒ Object
Constructor Details
#initialize(path, interface) ⇒ PatchEntity
Returns a new instance of PatchEntity.
16 17 18 19 |
# File 'lib/database_patcher/patch_entity.rb', line 16 def initialize(path, interface) @path = path @interface = interface end |
Instance Attribute Details
#interface ⇒ Object (readonly)
Returns the value of attribute interface.
15 16 17 |
# File 'lib/database_patcher/patch_entity.rb', line 15 def interface @interface end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
15 16 17 |
# File 'lib/database_patcher/patch_entity.rb', line 15 def path @path end |
Class Method Details
.factory(path, interface) ⇒ Object
7 8 9 10 11 12 13 |
# File 'lib/database_patcher/patch_entity.rb', line 7 def self.factory(path, interface) if ::File.directory?(path) self::Folder.new(path, interface) else self::File.new(path, interface) end end |
Instance Method Details
#down(_connection) ⇒ Object
35 36 37 |
# File 'lib/database_patcher/patch_entity.rb', line 35 def down(_connection) raise end |
#timestamp ⇒ Object
21 22 23 |
# File 'lib/database_patcher/patch_entity.rb', line 21 def basename.scan(/^\d+/).flatten.first.to_i end |
#uniq_indentifier ⇒ Object
39 40 41 42 43 44 |
# File 'lib/database_patcher/patch_entity.rb', line 39 def uniq_indentifier { timestamp: , uuid: uuid } end |
#up(_connection) ⇒ Object
31 32 33 |
# File 'lib/database_patcher/patch_entity.rb', line 31 def up(_connection) raise end |
#uuid ⇒ Object
26 27 28 29 |
# File 'lib/database_patcher/patch_entity.rb', line 26 def uuid basename = ::File.basename(@path, '.*') basename.scan(/^\d+_(#{UUID_MATCHER})_/).flatten.first.to_s end |