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.



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

#versionObject

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

#hashObject



41
42
43
# File 'lib/sequent/migrations/functions.rb', line 41

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

#table_nameObject



27
28
29
# File 'lib/sequent/migrations/functions.rb', line 27

def table_name
  @record_class.table_name
end