class URL::Service::Endpoint
Constants
- BUILT_IN_MAP
Define the built in methods and their fetcher aliases
- BUILT_IN_METHODS
Attributes
inflate_into[RW]
Public Class Methods
new(url)
click to toggle source
# File lib/url/endpoint.rb, line 40 def initialize url @base_url = @url = url end
Public Instance Methods
class_eval(*args,&blk)
click to toggle source
Expose class eval externally
# File lib/url/endpoint.rb, line 45 def class_eval *args,&blk eigenclass.class_eval *args,&blk end
eigenclass()
click to toggle source
# File lib/url/endpoint.rb, line 49 def eigenclass class << self; self; end end
inspect()
click to toggle source
# File lib/url/endpoint.rb, line 53 def inspect %Q{#<#{self.class} #{@url.to_s}>} end
method_inflate_into()
click to toggle source
Storage for what each endpoint should inflate into
# File lib/url/endpoint.rb, line 8 def method_inflate_into @method_inflate_into ||= {} end
Private Instance Methods
transform_response(resp, into=nil)
click to toggle source
# File lib/url/endpoint.rb, line 59 def transform_response resp, into=nil if resp.connection_refused raise EndpointNotResponding, resp.url_obj.host_with_port end if resp && !resp.empty? begin resp = resp.json rescue Exception => e warn "The response #{resp} couldn't be parsed" raise e end end if resp.is_a?(Hash) && (into ||= inflate_into) into.call(resp) else resp end end