Module: Traitify::Request
- Included in:
- Client
- Defined in:
- lib/traitify/request.rb
Instance Method Summary
collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(meth, *args, &block) ⇒ Object
3
4
5
6
7
8
9
|
# File 'lib/traitify/request.rb', line 3
def method_missing(meth, *args, &block)
if [:get, :post, :put, :delete].include? meth
request(meth, *args)
else
super
end
end
|
Instance Method Details
#request(method, path, options = {}) ⇒ Object
11
12
13
14
15
16
17
18
19
20
21
22
|
# File 'lib/traitify/request.rb', line 11
def request(method, path, options = {})
begin
conn(url: host).send(method) do |request|
request.url [version, path].join
request.body = options.to_json if options
end.body
rescue => e
puts e.message
puts e.inspect
{ error: e.message }
end
end
|