Class: CrashdeskRails::ActionControllerContext

Inherits:
Crashdesk::ContextBase
  • Object
show all
Defined in:
lib/crashdesk-rails/action_controller_context.rb

Instance Method Summary collapse

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_nameObject



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_nameObject



36
37
38
# File 'lib/crashdesk-rails/action_controller_context.rb', line 36

def controller_name
  @controller.class.to_s
end

#frameworkObject



24
25
26
# File 'lib/crashdesk-rails/action_controller_context.rb', line 24

def framework
  "rails"
end

#framework_versionObject



28
29
30
# File 'lib/crashdesk-rails/action_controller_context.rb', line 28

def framework_version
  Rails::VERSION::STRING
end

#headersObject



56
57
58
# File 'lib/crashdesk-rails/action_controller_context.rb', line 56

def headers
  extract_http_headers(@request.env)
end

#parametersObject



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_ipObject



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_methodObject



52
53
54
# File 'lib/crashdesk-rails/action_controller_context.rb', line 52

def request_method
  @request.request_method.to_s
end

#request_urlObject



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

#sessionObject



60
61
62
# File 'lib/crashdesk-rails/action_controller_context.rb', line 60

def session
  extract_session(@request)
end

#to_hashObject

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