Class: VelocityAudited::Sweeper
- Inherits:
-
Object
- Object
- VelocityAudited::Sweeper
- Defined in:
- lib/audited/sweeper.rb
Constant Summary collapse
- STORED_DATA =
{ current_remote_address: :remote_ip, current_request_uuid: :request_uuid, current_user: :current_user, origin: :origin, user_agent: :user_agent, uid: :uid, client: :client, request_id: :request_id }
Instance Method Summary collapse
- #around(controller) ⇒ Object
- #client ⇒ Object
- #controller ⇒ Object
- #controller=(value) ⇒ Object
- #current_user ⇒ Object
- #origin ⇒ Object
- #remote_ip ⇒ Object
- #request_id ⇒ Object
- #request_uuid ⇒ Object
- #uid ⇒ Object
- #user_agent ⇒ Object
Instance Method Details
#around(controller) ⇒ Object
18 19 20 21 22 23 24 25 |
# File 'lib/audited/sweeper.rb', line 18 def around(controller) self.controller = controller STORED_DATA.each { |k, m| store[k] = send(m) } yield ensure self.controller = nil STORED_DATA.keys.each { |k| store.delete(k) } end |
#client ⇒ Object
51 52 53 |
# File 'lib/audited/sweeper.rb', line 51 def client controller.try(:request).try(:headers)['client'] end |
#controller ⇒ Object
59 60 61 |
# File 'lib/audited/sweeper.rb', line 59 def controller store[:current_controller] end |
#controller=(value) ⇒ Object
63 64 65 |
# File 'lib/audited/sweeper.rb', line 63 def controller=(value) store[:current_controller] = value end |
#current_user ⇒ Object
27 28 29 |
# File 'lib/audited/sweeper.rb', line 27 def current_user lambda { controller.send(VelocityAudited.current_user_method) if controller.respond_to?(VelocityAudited.current_user_method, true) } end |
#origin ⇒ Object
39 40 41 |
# File 'lib/audited/sweeper.rb', line 39 def origin controller.try(:request).try(:headers)['Origin'] end |
#remote_ip ⇒ Object
31 32 33 |
# File 'lib/audited/sweeper.rb', line 31 def remote_ip controller.try(:request).try(:remote_ip) end |
#request_id ⇒ Object
55 56 57 |
# File 'lib/audited/sweeper.rb', line 55 def request_id controller.try(:request).try(:uuid) end |
#request_uuid ⇒ Object
35 36 37 |
# File 'lib/audited/sweeper.rb', line 35 def request_uuid controller.try(:request).try(:uuid) end |
#uid ⇒ Object
47 48 49 |
# File 'lib/audited/sweeper.rb', line 47 def uid controller.try(:request).try(:headers)['uid'] end |
#user_agent ⇒ Object
43 44 45 |
# File 'lib/audited/sweeper.rb', line 43 def user_agent controller.try(:request).try(:headers)['User-Agent'] end |