Class: FakeConsul::Server

Inherits:
HashWithIndifferentAccess
  • Object
show all
Defined in:
lib/fake_consul/server.rb

Instance Method Summary collapse

Instance Method Details

#get(key, options = nil, not_found = :reject, found = :return) ⇒ Array<Hash>

Fake get

Performs no http requests but stores data in local hash

Parameters:

  • key (String)
  • options (Hash) (defaults to: nil)
  • not_found (Symbol) (defaults to: :reject)

    unused/unimplemented

  • found (Symbol) (defaults to: :return)

    not unused/unimplemented

Returns:

  • (Array<Hash>)

    e.g. [‘foo’, value: ‘bar’]



14
15
16
17
18
19
20
21
22
# File 'lib/fake_consul/server.rb', line 14

def get(key, options = nil, not_found = :reject, found = :return)
  options ||= {}

  if options[: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

Parameters:

  • key (String)
  • options (Hash) (defaults to: nil)

    unused/unimplemented

Returns:

  • (Boolean)

    true :trollface:



31
32
33
34
# File 'lib/fake_consul/server.rb', line 31

def put(key, value, options = nil)
  self[key] = value
  true
end