Module: Praxis::Plugins::RailsPlugin::Controller
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/praxis/plugins/rails_plugin.rb
Instance Method Summary collapse
- #head(status, options = {}) ⇒ Object
-
#headers ⇒ Object
Allow accessing the response headers from the controller.
-
#params ⇒ Object
Expose a rails-version of params from the controller Avoid using them explicitly in your controllers though.
- #response_body=(body) ⇒ Object
- #session ⇒ Object
-
#status=(code) ⇒ Object
Allow setting the status and body of the response from the controller itself.
Instance Method Details
#head(status, options = {}) ⇒ Object
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/praxis/plugins/rails_plugin.rb', line 88 def head(status, = {}) if status.is_a?(Hash) = status status = nil end status ||= .delete(:status) || :ok location = .delete(:location) content_type = .delete(:content_type) code = Rack::Utils::SYMBOL_TO_STATUS_CODE[status] response = Praxis::Response.new(status: code, body: status.to_s, location: location) .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 ⇒ Object
Allow accessing the response headers from the controller
70 71 72 |
# File 'lib/praxis/plugins/rails_plugin.rb', line 70 def headers response.headers end |
#params ⇒ Object
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.
65 66 67 |
# File 'lib/praxis/plugins/rails_plugin.rb', line 65 def params request.parameters end |
#response_body=(body) ⇒ Object
83 84 85 86 |
# 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 ⇒ Object
74 75 76 |
# File 'lib/praxis/plugins/rails_plugin.rb', line 74 def session request.session end |
#status=(code) ⇒ Object
Allow setting the status and body of the response from the controller itself.
79 80 81 |
# File 'lib/praxis/plugins/rails_plugin.rb', line 79 def status=(code) response.status = code end |