request-auditor 0.0.1 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. data/lib/request-auditor.rb +32 -0
  2. metadata +2 -1
@@ -0,0 +1,32 @@
1
+ module Auditor
2
+ require 'engine' if defined?(Rails) && Rails::VERSION::MAJOR == 3
3
+ require 'application_controller'
4
+ end
5
+
6
+ module ActionController
7
+ module Auditor
8
+ def self.included(base)
9
+ base.extend(ClassMethods)
10
+ end
11
+
12
+ module ClassMethods
13
+ def is_audited
14
+ include ActionController::Auditor::InstanceMethods
15
+ before_filter :audit_request
16
+ end
17
+ end
18
+
19
+ module InstanceMethods
20
+ def audit_request
21
+ a = ::Auditor::AuditorLog.new
22
+ a.request_uri = request.url
23
+ a.request_parameters = request.filtered_parameters.inspect
24
+ a.remote_address = request.remote_ip
25
+ a.user_id = ::Auditor::Engine::config.user_id.call(request)
26
+ a.save!
27
+ end
28
+ end
29
+ end
30
+ end
31
+
32
+ ActionController::Base.send(:include, ActionController::Auditor)
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: request-auditor
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.1
5
+ version: 0.0.3
6
6
  platform: ruby
7
7
  authors:
8
8
  - Chris Hart
@@ -29,6 +29,7 @@ files:
29
29
  - lib/application_controller.rb
30
30
  - lib/application_helper.rb
31
31
  - lib/auditor.rb
32
+ - lib/request-auditor.rb
32
33
  - lib/engine.rb
33
34
  - lib/rails/generators/auditor/auditor_generator.rb
34
35
  - lib/rails/generators/auditor/templates/initializer.rb