Module: Leadlight::Service
- Extended by:
- Forwardable
- Defined in:
- lib/leadlight/service.rb
Instance Attribute Summary collapse
-
#error_handler ⇒ Object
Returns the value of attribute error_handler.
-
#service_options ⇒ Object
readonly
Returns the value of attribute service_options.
Instance Method Summary collapse
- #connection ⇒ Object
-
#get_representation!(*args, &block) ⇒ Object
Convenience method for a quick GET which submits, waits, raises on error, and yields the representation.
- #initialize(service_options = {}) ⇒ Object
- #on_error(&error_handler) ⇒ Object
- #root ⇒ Object
- #url ⇒ Object
Instance Attribute Details
#error_handler ⇒ Object
Returns the value of attribute error_handler.
11 12 13 |
# File 'lib/leadlight/service.rb', line 11 def error_handler @error_handler end |
#service_options ⇒ Object (readonly)
Returns the value of attribute service_options.
10 11 12 |
# File 'lib/leadlight/service.rb', line 10 def @service_options end |
Instance Method Details
#connection ⇒ Object
41 42 43 44 45 46 47 48 |
# File 'lib/leadlight/service.rb', line 41 def connection @connection ||= ConnectionBuilder.new do |cxn| cxn.url url cxn.service self cxn.common_stack common_connection_stack cxn.adapter http_adapter end.call end |
#get_representation!(*args, &block) ⇒ Object
Convenience method for a quick GET which submits, waits, raises on error, and yields the representation.
58 59 60 |
# File 'lib/leadlight/service.rb', line 58 def get_representation!(*args, &block) get(*args).raise_on_error.submit_and_wait(&block) end |
#initialize(service_options = {}) ⇒ Object
21 22 23 24 |
# File 'lib/leadlight/service.rb', line 21 def initialize(={}) @service_options = execute_hook(:on_init, self) end |
#on_error(&error_handler) ⇒ Object
26 27 28 29 |
# File 'lib/leadlight/service.rb', line 26 def on_error(&error_handler) self.error_handler = error_handler self end |
#root ⇒ Object
31 32 33 34 35 |
# File 'lib/leadlight/service.rb', line 31 def root get('/') do |r| return r end end |
#url ⇒ Object
37 38 39 |
# File 'lib/leadlight/service.rb', line 37 def url self.class.url end |