Class: RestData

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

Overview

stores rest service paths/responses

Instance Method Summary collapse

Constructor Details

#initialize(name = 'default') ⇒ RestData

Returns a new instance of RestData.



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

def initialize(name = 'default')
  @name = name
  @storage = {}
end

Instance Method Details

#add(path, message) ⇒ Object



8
9
10
# File 'lib/rest_data.rb', line 8

def add(path, message)
  @storage[path] = message
end

#get(path) ⇒ Object



12
13
14
15
16
17
# File 'lib/rest_data.rb', line 12

def get(path)
  return @storage[path] unless @storage[path].nil?
  file = "data/#{path}.txt"
  return File.read(file) if File.exist?(file)
  ''
end