Class: RestData
- Inherits:
-
Object
- Object
- RestData
- Defined in:
- lib/rest_data.rb
Overview
stores rest service paths/responses
Instance Method Summary collapse
- #add(path, message) ⇒ Object
- #get(path) ⇒ Object
-
#initialize(name = 'default') ⇒ RestData
constructor
A new instance of RestData.
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, ) @storage[path] = 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 |