Sha256: 5379bb89f57622d819190979ae19942917e354fa26966135df2abc104cf5f66c
Contents?: true
Size: 994 Bytes
Versions: 5
Compression:
Stored size: 994 Bytes
Contents
module Storyblok # This object represents a request that is to be made. It gets initialized by the client # with domain specific logic. The client later uses the Request's #url and #query methods # to execute the HTTP request. class Request attr_reader :client, :type, :query, :id, :endpoint def initialize(client, endpoint, query = {}, id = nil, bypass_cache = false) @client = client @endpoint = endpoint @query = query @bypass_cache = bypass_cache if id @type = :single @id = id else @type = :multi @id = nil end end # Returns the final URL, relative to a storyblok space def url "#{@endpoint}#{@type == :single ? "/#{id}" : ''}" end # Delegates the actual HTTP work to the client def get client.cached_get(self, @bypass_cache) end # Returns a new Request object with the same data def copy Marshal.load(Marshal.dump(self)) end end end
Version data entries
5 entries across 5 versions & 1 rubygems