Class: Munge::WriteManager

Inherits:
Object
  • Object
show all
Defined in:
lib/munge/write_manager.rb

Instance Method Summary collapse

Constructor Details

#initialize(driver:) ⇒ WriteManager

Returns a new instance of WriteManager.



3
4
5
6
# File 'lib/munge/write_manager.rb', line 3

def initialize(driver:)
  @driver      = driver
  @write_paths = []
end

Instance Method Details

#status(path, content) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/munge/write_manager.rb', line 8

def status(path, content)
  if @write_paths.include?(path)
    return :double_write_error
  end

  @write_paths.push(path)

  if !@driver.exist?(path)
    return :new
  end

  if @driver.read(path) == content
    return :identical
  end

  :changed
end