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.
24 25 26 27 |
# File 'lib/sequent/migrations/functions.rb', line 24 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.
21 22 23 |
# File 'lib/sequent/migrations/functions.rb', line 21 def record_class @record_class end |
#version ⇒ Object
Returns the value of attribute version.
22 23 24 |
# File 'lib/sequent/migrations/functions.rb', line 22 def version @version end |
Class Method Details
.inherited(child_class) ⇒ Object
14 15 16 17 18 19 |
# File 'lib/sequent/migrations/functions.rb', line 14 def self.inherited(child_class) super class << child_class include ClassMethods end end |
Instance Method Details
#==(other) ⇒ Object
37 38 39 40 41 |
# File 'lib/sequent/migrations/functions.rb', line 37 def ==(other) return false unless other.class == self.class table_name == other.table_name && version == other.version end |
#copy(with_version) ⇒ Object
33 34 35 |
# File 'lib/sequent/migrations/functions.rb', line 33 def copy(with_version) self.class.create(record_class, with_version) end |
#hash ⇒ Object
43 44 45 |
# File 'lib/sequent/migrations/functions.rb', line 43 def hash table_name.hash + (version&.hash || 0) end |
#table_name ⇒ Object
29 30 31 |
# File 'lib/sequent/migrations/functions.rb', line 29 def table_name @record_class.table_name end |