Class: Sequent::Migrations::Migration
- Inherits:
-
Object
- Object
- Sequent::Migrations::Migration
- Defined in:
- lib/sequent/migrations/functions.rb
Direct Known Subclasses
Defined Under Namespace
Modules: ClassMethods
Instance Attribute Summary collapse
-
#record_class ⇒ Object
readonly
Returns the value of attribute record_class.
-
#version ⇒ Object
Returns the value of attribute version.
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object
- #copy(with_version) ⇒ Object
- #hash ⇒ Object
-
#initialize(record_class) ⇒ Migration
constructor
A new instance of Migration.
- #table_name ⇒ Object
Constructor Details
#initialize(record_class) ⇒ Migration
Returns a new instance of Migration.
22 23 24 25 |
# File 'lib/sequent/migrations/functions.rb', line 22 def initialize(record_class) @record_class = record_class @version = nil end |
Instance Attribute Details
#record_class ⇒ Object (readonly)
Returns the value of attribute record_class.
19 20 21 |
# File 'lib/sequent/migrations/functions.rb', line 19 def record_class @record_class end |
#version ⇒ Object
Returns the value of attribute version.
20 21 22 |
# File 'lib/sequent/migrations/functions.rb', line 20 def version @version end |
Class Method Details
.inherited(child_class) ⇒ Object
13 14 15 16 17 |
# File 'lib/sequent/migrations/functions.rb', line 13 def self.inherited(child_class) class << child_class include ClassMethods end end |
Instance Method Details
#==(other) ⇒ Object
35 36 37 38 39 |
# File 'lib/sequent/migrations/functions.rb', line 35 def ==(other) return false unless other.class == self.class self.table_name == other.table_name && version == other.version end |
#copy(with_version) ⇒ Object
31 32 33 |
# File 'lib/sequent/migrations/functions.rb', line 31 def copy(with_version) self.class.create(record_class, with_version) end |
#hash ⇒ Object
41 42 43 |
# File 'lib/sequent/migrations/functions.rb', line 41 def hash self.table_name.hash + (version&.hash || 0) end |
#table_name ⇒ Object
27 28 29 |
# File 'lib/sequent/migrations/functions.rb', line 27 def table_name @record_class.table_name end |