Class: Lhm::Migration

Inherits:
Object
  • Object
show all
Defined in:
lib/lhm/migration.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(origin, destination, conditions = nil, renames = {}, time = Time.now) ⇒ Migration

Returns a new instance of Migration.



11
12
13
14
15
16
17
# File 'lib/lhm/migration.rb', line 11

def initialize(origin, destination, conditions = nil, renames = {}, time = Time.now)
  @origin = origin
  @destination = destination
  @conditions = conditions
  @renames = renames
  @table_name = TableName.new(@origin.name, time)
end

Instance Attribute Details

#conditionsObject (readonly)

Returns the value of attribute conditions.



9
10
11
# File 'lib/lhm/migration.rb', line 9

def conditions
  @conditions
end

#destinationObject (readonly)

Returns the value of attribute destination.



9
10
11
# File 'lib/lhm/migration.rb', line 9

def destination
  @destination
end

#originObject (readonly)

Returns the value of attribute origin.



9
10
11
# File 'lib/lhm/migration.rb', line 9

def origin
  @origin
end

#renamesObject (readonly)

Returns the value of attribute renames.



9
10
11
# File 'lib/lhm/migration.rb', line 9

def renames
  @renames
end

Instance Method Details

#archive_nameObject



19
20
21
# File 'lib/lhm/migration.rb', line 19

def archive_name
  @archive_name ||= @table_name.archived
end

#destination_columnsObject



39
40
41
# File 'lib/lhm/migration.rb', line 39

def destination_columns
  @destination_columns ||= intersection.destination.joined
end

#destination_nameObject



35
36
37
# File 'lib/lhm/migration.rb', line 35

def destination_name
  @destination_name ||= destination.name
end

#intersectionObject



23
24
25
# File 'lib/lhm/migration.rb', line 23

def intersection
  Intersection.new(@origin, @destination, @renames)
end

#origin_columnsObject



31
32
33
# File 'lib/lhm/migration.rb', line 31

def origin_columns
  @origin_columns ||= intersection.origin.typed(origin_name)
end

#origin_nameObject



27
28
29
# File 'lib/lhm/migration.rb', line 27

def origin_name
  @table_name.original
end