Class: FakeConsul::Server
- Inherits:
-
HashWithIndifferentAccess
- Object
- HashWithIndifferentAccess
- FakeConsul::Server
- Defined in:
- lib/fake_consul/server.rb
Instance Method Summary collapse
-
#clear ⇒ Object
Clear current data and delete backing marshalling file.
-
#delete(key, options = nil) ⇒ Boolean
Fake delete.
-
#get(key, options = nil, not_found = :reject, found = :return) ⇒ Array<Hash>
Fake get.
-
#initialize ⇒ Server
constructor
A new instance of Server.
-
#put(key, value, options = nil) ⇒ Boolean
Fake put.
Constructor Details
#initialize ⇒ Server
Returns a new instance of Server.
7 8 9 |
# File 'lib/fake_consul/server.rb', line 7 def initialize restore! end |
Instance Method Details
#clear ⇒ Object
Clear current data and delete backing marshalling file
61 62 63 64 65 |
# File 'lib/fake_consul/server.rb', line 61 def clear super return unless File.exist?(db_file) File.delete(db_file) end |
#delete(key, options = nil) ⇒ Boolean
Fake delete
Performs no http requests but deletes data from local hash
52 53 54 55 56 57 |
# File 'lib/fake_consul/server.rb', line 52 def delete(key, = nil) super(key) compact persist! true end |
#get(key, options = nil, not_found = :reject, found = :return) ⇒ Array<Hash>
Fake get
Performs no http requests but stores data in local hash
21 22 23 24 25 26 27 28 29 |
# File 'lib/fake_consul/server.rb', line 21 def get(key, = nil, not_found = :reject, found = :return) ||= {} if [:recurse] find_keys_recursive(key) else consul_export_format(key) end end |
#put(key, value, options = nil) ⇒ Boolean
Fake put
Performs no http requests but retrieves data from local hash
38 39 40 41 42 43 |
# File 'lib/fake_consul/server.rb', line 38 def put(key, value, = nil) self[key] = value compact persist! true end |