Class: Hook::Client
- Inherits:
-
Object
- Object
- Hook::Client
- Defined in:
- lib/hook-client/client.rb
Class Attribute Summary collapse
-
.instance ⇒ Object
readonly
Returns the value of attribute instance.
Class Method Summary collapse
Instance Method Summary collapse
- #auth ⇒ Object
- #channel(name, options = {}) ⇒ Object
- #collection(name) ⇒ Object
- #files ⇒ Object
- #get(segments, data = {}) ⇒ Object
-
#initialize(options = {}) ⇒ Client
constructor
A new instance of Client.
- #keys ⇒ Object
- #logger=(logger) ⇒ Object
- #post(segments, data) ⇒ Object
- #put(segments, data) ⇒ Object
- #remove(segments, data = {}) ⇒ Object (also: #delete)
Constructor Details
#initialize(options = {}) ⇒ Client
Returns a new instance of Client.
13 14 15 16 17 18 19 20 |
# File 'lib/hook-client/client.rb', line 13 def initialize = {} @app_id = .delete(:app_id) @key = .delete(:key) @endpoint = .delete(:endpoint) || .delete(:url) @endpoint = "#{@endpoint}/" unless @endpoint.end_with? "/" @logger = .delete(:logger) end |
Class Attribute Details
.instance ⇒ Object (readonly)
Returns the value of attribute instance.
7 8 9 |
# File 'lib/hook-client/client.rb', line 7 def instance @instance end |
Class Method Details
.configure(options = {}) ⇒ Object
8 9 10 |
# File 'lib/hook-client/client.rb', line 8 def configure( = {}) @instance = self.new() end |
Instance Method Details
#auth ⇒ Object
26 27 28 |
# File 'lib/hook-client/client.rb', line 26 def auth Auth.new end |
#channel(name, options = {}) ⇒ Object
42 43 44 45 |
# File 'lib/hook-client/client.rb', line 42 def channel(name, = {}) throw NotImplementedError.new("channels not implemented") Channel.create(self, name, ) end |
#collection(name) ⇒ Object
34 35 36 |
# File 'lib/hook-client/client.rb', line 34 def collection(name) Collection.new(:name => name, :client => self) end |
#files ⇒ Object
30 31 32 |
# File 'lib/hook-client/client.rb', line 30 def files Files.new end |
#get(segments, data = {}) ⇒ Object
51 52 53 |
# File 'lib/hook-client/client.rb', line 51 def get segments, data = {} request :get, segments, data end |
#logger=(logger) ⇒ Object
38 39 40 |
# File 'lib/hook-client/client.rb', line 38 def logger=(logger) @logger = logger end |
#post(segments, data) ⇒ Object
47 48 49 |
# File 'lib/hook-client/client.rb', line 47 def post segments, data request :post, segments, data end |
#put(segments, data) ⇒ Object
55 56 57 |
# File 'lib/hook-client/client.rb', line 55 def put segments, data request :put, segments, data end |
#remove(segments, data = {}) ⇒ Object Also known as: delete
59 60 61 |
# File 'lib/hook-client/client.rb', line 59 def remove segments, data = {} request :delete, segments, data end |