Module: Morale::Storage

Included in:
ConnectionStore
Defined in:
lib/morale/storage.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#locationObject

Returns the value of attribute location.



4
5
6
# File 'lib/morale/storage.rb', line 4

def location
  @location
end

Instance Method Details

#deleteObject



6
7
8
# File 'lib/morale/storage.rb', line 6

def delete
  FileUtils.rm_f(location)
end

#readObject



10
11
12
# File 'lib/morale/storage.rb', line 10

def read
  File.exists?(location) and File.read(location)
end

#write(data) ⇒ Object



14
15
16
17
18
19
20
# File 'lib/morale/storage.rb', line 14

def write(data)
  FileUtils.mkdir_p(File.dirname(location))
  f = File.open(location, 'w')
  f.puts data
  f.close
  set_permissions
end