Sha256: 3ee7c56d1da7e7d207452f1af3ba7b7f5e34c7b54d8fd6ea0a7e7b2996fa66af

Contents?: true

Size: 679 Bytes

Versions: 5

Compression:

Stored size: 679 Bytes

Contents

module YouGotListed
  class Response
    
    attr_accessor :ygl_response
    
    def initialize(response, raise_error = true)
      rash = Hashie::Rash.new(response)
      self.ygl_response = rash.ygl_response
      raise Error.new(self.ygl_response.response_code, self.ygl_response.error) if !success? && raise_error
    end
    
    def success?
      self.ygl_response && self.ygl_response.respond_to?(:response_code) && self.ygl_response.response_code.to_i < 300
    end
    
    def method_missing(method_name, *args)
      if self.ygl_response.respond_to?(method_name)
        self.ygl_response.send(method_name)
      else
        super
      end
    end
    
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
you_got_listed-0.3.3 lib/you_got_listed/response.rb
you_got_listed-0.3.2 lib/you_got_listed/response.rb
you_got_listed-0.3.1 lib/you_got_listed/response.rb
you_got_listed-0.3.0 lib/you_got_listed/response.rb
you_got_listed-0.2.5 lib/you_got_listed/response.rb