Sha256: 0b14295a66299e2d91f4dab4c0dbefe9fb871b06817cab979bd651aaabee91e8
Contents?: true
Size: 934 Bytes
Versions: 8
Compression:
Stored size: 934 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) @client = client @endpoint = endpoint @query = query if id @type = :single @id = URI.escape(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) end # Returns a new Request object with the same data def copy Marshal.load(Marshal.dump(self)) end end end
Version data entries
8 entries across 8 versions & 1 rubygems