Class: Sequent::Migrations::Migration

Inherits:
Object
  • Object
show all
Defined in:
lib/sequent/migrations/functions.rb

Direct Known Subclasses

AlterTable, ReplayTable

Defined Under Namespace

Modules: ClassMethods

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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_classObject (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

#versionObject

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

#hashObject



43
44
45
# File 'lib/sequent/migrations/functions.rb', line 43

def hash
  table_name.hash + (version&.hash || 0)
end

#table_nameObject



29
30
31
# File 'lib/sequent/migrations/functions.rb', line 29

def table_name
  @record_class.table_name
end