Class: RhetButler::Stasis::Writer

Inherits:
Object
  • Object
show all
Defined in:
lib/rhet-butler/stasis/writer.rb

Direct Known Subclasses

ValiseWriter

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(root) ⇒ Writer

Returns a new instance of Writer.



5
6
7
# File 'lib/rhet-butler/stasis/writer.rb', line 5

def initialize(root)
  @root = root
end

Instance Attribute Details

#store_logObject

Returns the value of attribute store_log.



8
9
10
# File 'lib/rhet-butler/stasis/writer.rb', line 8

def store_log
  @store_log
end

Instance Method Details

#store(path, content) ⇒ Object



15
16
17
18
19
# File 'lib/rhet-butler/stasis/writer.rb', line 15

def store(path, content)
  File::open(File::join(@root, path), "w") do |file|
    file.write(content)
  end
end

#write(path, content) ⇒ Object



10
11
12
13
# File 'lib/rhet-butler/stasis/writer.rb', line 10

def write(path, content)
  store_log.puts "Writing: #{path}" if store_log.respond_to? :puts
  store(path, content)
end