Sha256: caeb3af05dcb68af719ad403f72a77497a5e3d804f0941af4e60efcb2846c2bd
Contents?: true
Size: 1.2 KB
Versions: 1
Compression:
Stored size: 1.2 KB
Contents
module Weasel def audit_with_weasel(*args) around_filter :audit, only: args end module Auditable def audit yield return unless user.present? Weasel::EventsWorker.perform_async(user.id, thin_request) end private def user if defined?(current_user) current_user elsif defined?(current_admin) current_admin end end def thin_request parameters = request.params rails_action = "#{parameters[:controller]}:#{parameters[:action]}" rails_parameters = parameters.except(:controller, :action) { action: rails_action, params: rails_parameters, remote_ip: request.remote_ip, geo_ip_information: geo_ip_information, user_agent: request.user_agent, response: { status: response.status }.tap do |hash| hash[:body] = response.body if response.body end }.tap do |hash| hash[:flash] = request.flash if request.flash end end def geo_ip_information geo_service.country(request.remote_ip).to_h end def geo_service @@geoip ||= GeoIP.new(File.join(Rails.root, 'tmp/GeoIP.dat')) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
weasel-0.2.2 | lib/weasel/concerns/auditable.rb |