Module: Dagger::Wrapper
- Defined in:
- lib/dagger/wrapper.rb
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
Instance Method Summary collapse
- #connect(&block) ⇒ Object
- #delete(path, params = {}, opts = {}) ⇒ Object
- #disconnect ⇒ Object
- #get(path, params = {}, opts = {}) ⇒ Object
- #initialize(opts = {}) ⇒ Object
- #patch(path, params = {}, opts = {}) ⇒ Object
- #post(path, params = {}, opts = {}) ⇒ Object
- #put(path, params = {}, opts = {}) ⇒ Object
- #request(method, path, params = {}, opts = nil) ⇒ Object
Class Method Details
.included(base) ⇒ Object
7 8 9 |
# File 'lib/dagger/wrapper.rb', line 7 def self.included(base) base.extend(ClassMethods) end |
Instance Method Details
#connect(&block) ⇒ Object
63 64 65 66 67 68 69 70 71 |
# File 'lib/dagger/wrapper.rb', line 63 def connect(&block) open_http if block_given? yield close_http else at_exit { close_http } end end |
#delete(path, params = {}, opts = {}) ⇒ Object
50 51 52 |
# File 'lib/dagger/wrapper.rb', line 50 def delete(path, params = {}, opts = {}) request(:delete, path, params, opts) end |
#disconnect ⇒ Object
73 74 75 |
# File 'lib/dagger/wrapper.rb', line 73 def disconnect close_http end |
#get(path, params = {}, opts = {}) ⇒ Object
34 35 36 |
# File 'lib/dagger/wrapper.rb', line 34 def get(path, params = {}, opts = {}) request(:get, path, params, opts) end |
#initialize(opts = {}) ⇒ Object
29 30 31 32 |
# File 'lib/dagger/wrapper.rb', line 29 def initialize(opts = {}) @logger = opts.delete(:logger) @options = opts end |
#patch(path, params = {}, opts = {}) ⇒ Object
46 47 48 |
# File 'lib/dagger/wrapper.rb', line 46 def patch(path, params = {}, opts = {}) request(:patch, path, params, opts) end |
#post(path, params = {}, opts = {}) ⇒ Object
38 39 40 |
# File 'lib/dagger/wrapper.rb', line 38 def post(path, params = {}, opts = {}) request(:post, path, params, opts) end |
#put(path, params = {}, opts = {}) ⇒ Object
42 43 44 |
# File 'lib/dagger/wrapper.rb', line 42 def put(path, params = {}, opts = {}) request(:put, path, params, opts) end |
#request(method, path, params = {}, opts = nil) ⇒ Object
54 55 56 57 58 59 60 61 |
# File 'lib/dagger/wrapper.rb', line 54 def request(method, path, params = {}, opts = nil) url = self.class.base_url + path resp = benchmark("#{method} #{path}") do http.request(method, url, params, .merge(opts)) end handle_response(resp, method, path, params) end |