Module: Leadlight::Service

Extended by:
Forwardable
Defined in:
lib/leadlight/service.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#service_optionsObject (readonly)

Returns the value of attribute service_options.



9
10
11
# File 'lib/leadlight/service.rb', line 9

def service_options
  @service_options
end

Instance Method Details

#connectionObject



33
34
35
36
37
38
39
40
# File 'lib/leadlight/service.rb', line 33

def connection
  @connection ||= Faraday.new(url: self.url) do |builder|
    builder.use Leadlight::ServiceMiddleware, service: self
    instance_exec(builder, &connection_stack)
    builder.use Faraday::Response::Logger, logger
    instance_exec(builder, &Leadlight.common_connection_stack)
  end
end

#get_representation!(*args, &block) ⇒ Object

Convenience method for a quick GET which submits, waits, raises on error, and yields the representation.



50
51
52
# File 'lib/leadlight/service.rb', line 50

def get_representation!(*args, &block)
  get(*args).raise_on_error.submit_and_wait(&block)
end

#initialize(service_options = {}) ⇒ Object



18
19
20
21
# File 'lib/leadlight/service.rb', line 18

def initialize(service_options={})
  @service_options = service_options
  execute_hook(:on_init, self)
end

#rootObject



23
24
25
26
27
# File 'lib/leadlight/service.rb', line 23

def root
  get('/') do |r|
    return r
  end
end

#urlObject



29
30
31
# File 'lib/leadlight/service.rb', line 29

def url
  self.class.url
end