class Gizmo::BaseOperation

Attributes

context[R]

Public Class Methods

new(context) click to toggle source

Creates a new Find and sets its context

@param [Gizmo::Context] context

# File lib/gizmo/base_operation.rb, line 9
def initialize(context)
  @context = context
end

Public Instance Methods

create_response() click to toggle source
# File lib/gizmo/base_operation.rb, line 13
def create_response
  Response.new(format: context.format, callback: context.callback, status: default_status)
end
default_status() click to toggle source
# File lib/gizmo/base_operation.rb, line 17
def default_status
  200
end
set_response_headers(gizmo_response) click to toggle source

Set headers on the response

@param [Gizmo::Response] gizmo_response a response used to set headers on the HTTP response

# File lib/gizmo/base_operation.rb, line 24
def set_response_headers(gizmo_response)
  if context.gizmo.respond_to?(:headers) && gizmo_response.headers
    gizmo_response.headers.each do |name, value|
      context.gizmo.headers[name] = value
    end
  end
end