Module: Response

Defined in:
lib/primate/response.rb

Class Method Summary collapse

Class Method Details

.error(options = {}) ⇒ Hash

Create an error response

Parameters:

  • options (Hash) (defaults to: {})

    Error options

Returns:

  • (Hash)

    Response object for the Primate framework



27
28
29
# File 'lib/primate/response.rb', line 27

def self.error(options = {})
  { __PRMT__: 'error', options: options }
end

.redirect(location, options = {}) ⇒ Hash

Create a redirect response

Parameters:

  • location (String)

    URL to redirect to

  • options (Hash) (defaults to: {})

    Redirect options (status code, etc.)

Returns:

  • (Hash)

    Response object for the Primate framework



19
20
21
# File 'lib/primate/response.rb', line 19

def self.redirect(location, options = {})
  { __PRMT__: 'redirect', location: location, options: options }
end

.view(name, props = {}, options = {}) ⇒ Hash

Create a view response

Parameters:

  • name (String)

    The view template name

  • props (Hash) (defaults to: {})

    Props to pass to the view

  • options (Hash) (defaults to: {})

    Additional view options

Returns:

  • (Hash)

    Response object for the Primate framework



10
11
12
# File 'lib/primate/response.rb', line 10

def self.view(name, props = {}, options = {})
  { __PRMT__: 'view', name: name, props: props, options: options }
end