Class: Reflect::Client
- Inherits:
-
Object
- Object
- Reflect::Client
- Includes:
- HTTParty
- Defined in:
- lib/reflect/client.rb
Instance Method Summary collapse
- #delete(path) ⇒ Object
- #get(path) ⇒ Object
-
#initialize(token) ⇒ Client
constructor
A new instance of Client.
- #keyspace(slug) ⇒ Object
- #patch(path, content, headers = {}) ⇒ Object
- #post(path, content) ⇒ Object
- #put(path, content) ⇒ Object
Constructor Details
#initialize(token) ⇒ Client
Returns a new instance of Client.
12 13 14 |
# File 'lib/reflect/client.rb', line 12 def initialize(token) @token = token end |
Instance Method Details
#delete(path) ⇒ Object
39 40 41 42 |
# File 'lib/reflect/client.rb', line 39 def delete(path) logger.debug { "[reflect] Sending DELETE #{URI.encode(path)}" } self.class.delete(URI.encode(path), ) end |
#get(path) ⇒ Object
27 28 29 |
# File 'lib/reflect/client.rb', line 27 def get(path) self.class.get(URI.encode(path), ) end |
#keyspace(slug) ⇒ Object
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/reflect/client.rb', line 16 def keyspace(slug) res = get("/v1/keyspaces/#{slug}") if res.response.code == "200" Keyspace.new(self, JSON.parse(res.body)) else # TODO: What happens if we failed to look this up or whatever? raise Reflect::RequestError, Reflect.(res) end end |
#patch(path, content, headers = {}) ⇒ Object
44 45 46 47 48 |
# File 'lib/reflect/client.rb', line 44 def patch(path, content, headers={}) opts = (body: dump(content)) opts[:headers].merge!(headers) unless headers.empty? self.class.patch(path, opts) end |
#post(path, content) ⇒ Object
31 32 33 |
# File 'lib/reflect/client.rb', line 31 def post(path, content) self.class.post(URI.encode(path), (body: dump(content))) end |
#put(path, content) ⇒ Object
35 36 37 |
# File 'lib/reflect/client.rb', line 35 def put(path, content) self.class.put(URI.encode(path), (body: dump(content))) end |