lib/lazy_resource/request.rb in lazy_resource-0.3.3 vs lib/lazy_resource/request.rb in lazy_resource-0.4.0
- old
+ new
@@ -12,21 +12,17 @@
options[:method] ||= :get
super(url, options)
@resource = resource
- self.on_complete = on_complete_proc
-
- self
- end
-
- def on_complete_proc
- Proc.new do |response|
+ self.on_complete do
log_response(response) if LazyResource.debug && LazyResource.logger
@response = response
handle_errors unless SUCCESS_STATUSES.include?(@response.code)
parse
end
+
+ self
end
def log_response(response)
LazyResource.logger.info "\t[#{response.code}](#{((response.time || 0) * 1000).ceil}ms): #{self.url}"
end