Class: CrashdeskRails::ActionControllerContext
- Inherits:
-
Crashdesk::ContextBase
- Object
- Crashdesk::ContextBase
- CrashdeskRails::ActionControllerContext
- Defined in:
- lib/crashdesk-rails/action_controller_context.rb
Instance Method Summary collapse
- #action_name ⇒ Object
- #controller_name ⇒ Object
- #framework ⇒ Object
- #framework_version ⇒ Object
- #headers ⇒ Object
-
#initialize(controller, request) ⇒ ActionControllerContext
constructor
A new instance of ActionControllerContext.
- #parameters ⇒ Object
- #remote_ip ⇒ Object
- #request_method ⇒ Object
- #request_url ⇒ Object
- #session ⇒ Object
-
#to_hash ⇒ Object
Extract all meaningfull data from our controller.
Constructor Details
#initialize(controller, request) ⇒ ActionControllerContext
Returns a new instance of ActionControllerContext.
5 6 7 8 |
# File 'lib/crashdesk-rails/action_controller_context.rb', line 5 def initialize(controller, request) @controller = controller @request = request end |
Instance Method Details
#action_name ⇒ Object
40 41 42 |
# File 'lib/crashdesk-rails/action_controller_context.rb', line 40 def action_name @request.respond_to?(:parameters) ? @request.parameters['action'] : @request.params['action'] end |
#controller_name ⇒ Object
36 37 38 |
# File 'lib/crashdesk-rails/action_controller_context.rb', line 36 def controller_name @controller.class.to_s end |
#framework ⇒ Object
24 25 26 |
# File 'lib/crashdesk-rails/action_controller_context.rb', line 24 def framework "rails" end |
#framework_version ⇒ Object
28 29 30 |
# File 'lib/crashdesk-rails/action_controller_context.rb', line 28 def framework_version Rails::VERSION::STRING end |
#headers ⇒ Object
56 57 58 |
# File 'lib/crashdesk-rails/action_controller_context.rb', line 56 def headers extract_http_headers(@request.env) end |
#parameters ⇒ Object
48 49 50 |
# File 'lib/crashdesk-rails/action_controller_context.rb', line 48 def parameters filter_parameters(@request.respond_to?(:parameters) ? @request.parameters : @request.params) end |
#remote_ip ⇒ Object
44 45 46 |
# File 'lib/crashdesk-rails/action_controller_context.rb', line 44 def remote_ip @request.respond_to?(:remote_ip) ? @request.remote_ip : @request.ip end |
#request_method ⇒ Object
52 53 54 |
# File 'lib/crashdesk-rails/action_controller_context.rb', line 52 def request_method @request.request_method.to_s end |
#request_url ⇒ Object
32 33 34 |
# File 'lib/crashdesk-rails/action_controller_context.rb', line 32 def request_url @request.respond_to?(:url) ? @request.url : "#{@request.protocol}#{@request.host}#{@request.request_uri}" end |
#session ⇒ Object
60 61 62 |
# File 'lib/crashdesk-rails/action_controller_context.rb', line 60 def session extract_session(@request) end |
#to_hash ⇒ Object
Extract all meaningfull data from our controller.
11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/crashdesk-rails/action_controller_context.rb', line 11 def to_hash { 'url' => request_url, 'controller_name' => controller_name, 'action_name' => action_name, 'parameters' => parameters, 'request_method' => request_method, 'remote_ip' => remote_ip, 'headers' => headers, 'session' => session } end |