Sha256: 196a78bafaf82a1bf6cb81a521648fdd85306f9095fbd74a6da566848fc3b113
Contents?: true
Size: 863 Bytes
Versions: 1
Compression:
Stored size: 863 Bytes
Contents
require 'hashie' module Galactus class Response < Hash include Hashie::Extensions::MergeInitializer include Hashie::Extensions::MethodAccess include Hashie::Extensions::IndifferentAccess include Hashie::Extensions::KeyConversion attr_reader :raw_response def self.create(response) case response.code when 200 Response.new(response) when 304 NotModifiedResponse.new(response) else ErrorResponse.new(response) end end def initialize(response) @raw_response = response super(response) end end class ErrorResponse < Response; end class NotModifiedResponse < Response def initialize(response) super({ status: 'Not Modified', code: 304, data: {}, etag: response.headers['etag'] }) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
galactus-0.2.0 | lib/galactus/response.rb |