module Praxis::Plugins::RailsPlugin::Controller

Public Instance Methods

head(status, options = {}) click to toggle source
# File lib/praxis/plugins/rails_plugin.rb, line 88
def head(status, options = {})
  if status.is_a?(Hash)
    options = status
    status = nil
  end
  status ||= options.delete(:status) || :ok
  location = options.delete(:location)
  content_type = options.delete(:content_type)

  code = Rack::Utils::SYMBOL_TO_STATUS_CODE[status]
  response = Praxis::Response.new(status: code, body: status.to_s, location: location)

  options.each do |key, value|
    response.headers[key.to_s.dasherize.split('-').each { |v| v[0] = v[0].chr.upcase }.join('-')] = value.to_s
  end
  response.content_type = content_type if content_type
  response
end
headers() click to toggle source

Allow accessing the response headers from the controller

# File lib/praxis/plugins/rails_plugin.rb, line 70
def headers
  response.headers
end
params() click to toggle source

Expose a rails-version of params from the controller Avoid using them explicitly in your controllers though. Use request.params object instead, as they are the Praxis ones that have been validated and coerced into the types you’ve defined.

# File lib/praxis/plugins/rails_plugin.rb, line 65
def params
  request.parameters
end
response_body=(body) click to toggle source
# File lib/praxis/plugins/rails_plugin.rb, line 83
def response_body=(body)
  # TODO: @_rendered = true # Necessary to know if to stop filter chain or not...
  response.body = body
end
session() click to toggle source
# File lib/praxis/plugins/rails_plugin.rb, line 74
def session
  request.session
end
status=(code) click to toggle source

Allow setting the status and body of the response from the controller itself.

# File lib/praxis/plugins/rails_plugin.rb, line 79
def status=(code)
  response.status = code
end