Class: DatabasePatcher::Fetcher

Inherits:
Object
  • Object
show all
Defined in:
lib/database_patcher/fetcher.rb

Instance Method Summary collapse

Constructor Details

#initialize(connection) ⇒ Fetcher

Returns a new instance of Fetcher.



3
4
5
# File 'lib/database_patcher/fetcher.rb', line 3

def initialize(connection)
  @connection = connection
end

Instance Method Details

#get_intalled_patchesObject



7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/database_patcher/fetcher.rb', line 7

def get_intalled_patches
  patches = get_patches.reverse
  installed_patches = []
  already_applied_patch_timestamps = get_already_applied_patch_timestamps

  patches.each do |patch|
    break unless already_applied_patch_timestamps.include?(patch.timestamp)
    installed_patches.push(patch)
  end

  installed_patches
end

#get_pending_patchesObject



20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/database_patcher/fetcher.rb', line 20

def get_pending_patches
  patches = get_patches
  pending_patches = []
  already_applied_patch_timestamps = get_already_applied_patch_timestamps

  patches.each do |patch|
    break if already_applied_patch_timestamps.include?(patch.timestamp)
    pending_patches.push(patch)
  end

  pending_patches
end