lib/leadlight/service.rb in leadlight-0.0.2 vs lib/leadlight/service.rb in leadlight-0.0.3
- old
+ new
@@ -8,16 +8,18 @@
attr_reader :service_options
fattr(:logger) { service_options.fetch(:logger) { ::Logger.new($stderr) } }
fattr(:tints) { self.class.tints }
fattr(:codec) { service_options.fetch(:codec) { Codec.new } }
+ fattr(:type_map) { TypeMap.new }
def_delegators :codec, :encode, :decode
- def_delegators 'self.class', :types, :type_for_name
+ def_delegators 'self.class', :types, :type_for_name, :request_class
def initialize(service_options={})
@service_options = service_options
+ execute_hook(:on_init, self)
end
def root
get('/') do |r|
return r
@@ -50,21 +52,14 @@
end
private
def perform_request(url, http_method, params={}, body=nil, &representation_handler)
- req = Request.new(connection, url, http_method, params, body)
- req.on_prepare_request do |faraday_request|
- prepare_request(faraday_request)
- end
+ req = request_class.new(self, connection, url, http_method, params, body)
if representation_handler
req.submit_and_wait(&representation_handler)
end
req
- end
-
- def prepare_request(request)
- # Override in subclasses
end
def connection_stack
self.class.connection_stack
end