Object
# File lib/typhoeus/remote_proxy_object.rb, line 5 5: def initialize(clear_memoized_store_proc, easy, options = {}) 6: @clear_memoized_store_proc = clear_memoized_store_proc 7: @easy = easy 8: @success = options[:on_success] 9: @failure = options[:on_failure] 10: @cache = options.delete(:cache) 11: @cache_key = options.delete(:cache_key) 12: @timeout = options.delete(:cache_timeout) 13: Typhoeus.add_easy_request(@easy) 14: end
# File lib/typhoeus/remote_proxy_object.rb, line 16 16: def method_missing(sym, *args, &block) 17: unless @proxied_object 18: if @cache && @cache_key 19: @proxied_object = @cache.get(@cache_key) rescue nil 20: end 21: 22: unless @proxied_object 23: Typhoeus.perform_easy_requests 24: response = Response.new(:code => @easy.response_code, 25: :headers => @easy.response_header, 26: :body => @easy.response_body, 27: :time => @easy.total_time_taken, 28: :requested_url => @easy.url, 29: :requested_http_method => @easy.method, 30: :start_time => @easy.start_time) 31: if @easy.response_code >= 200 && @easy.response_code < 300 32: Typhoeus.release_easy_object(@easy) 33: @proxied_object = @success.nil? ? response : @success.call(response) 34: 35: if @cache && @cache_key 36: @cache.set(@cache_key, @proxied_object, @timeout) 37: end 38: else 39: @proxied_object = @failure.nil? ? response : @failure.call(response) 40: end 41: @clear_memoized_store_proc.call 42: end 43: end 44: 45: @proxied_object.__send__(sym, *args, &block) 46: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.