Sha256: b5823ce66199c9383af97a7354c1cedddc8a22177b61339604065b82d1f11b91

Contents?: true

Size: 609 Bytes

Versions: 5

Compression:

Stored size: 609 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.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.2.4 lib/you_got_listed/response.rb
you_got_listed-0.2.3 lib/you_got_listed/response.rb
you_got_listed-0.2.2 lib/you_got_listed/response.rb
you_got_listed-0.2.1 lib/you_got_listed/response.rb
you_got_listed-0.2.0 lib/you_got_listed/response.rb