Class: ActiveRecord::Snapshot::Version

Inherits:
Object
  • Object
show all
Defined in:
lib/active_record/snapshot/files/version.rb

Class Method Summary collapse

Class Method Details

.currentObject



5
6
7
8
# File 'lib/active_record/snapshot/files/version.rb', line 5

def current
  return nil unless File.file?(path)
  ::File.read(path).to_i
end

.downloadObject



23
24
25
# File 'lib/active_record/snapshot/files/version.rb', line 23

def download
  s3.download_to(path)
end

.filenameObject



31
32
33
# File 'lib/active_record/snapshot/files/version.rb', line 31

def filename
  "snapshot_version".freeze
end

.incrementObject



14
15
16
# File 'lib/active_record/snapshot/files/version.rb', line 14

def increment
  File.write(path, self.next)
end

.nextObject



10
11
12
# File 'lib/active_record/snapshot/files/version.rb', line 10

def next
  current + 1
end

.pathObject



35
36
37
# File 'lib/active_record/snapshot/files/version.rb', line 35

def path
  config.store.local.join(filename).to_s.freeze
end

.uploadObject



27
28
29
# File 'lib/active_record/snapshot/files/version.rb', line 27

def upload
  s3.upload(path)
end

.write(version) ⇒ Object



18
19
20
21
# File 'lib/active_record/snapshot/files/version.rb', line 18

def write(version)
  return false unless version.to_i.to_s == version.to_s
  File.write(path, version)
end