Sha256: 97e0fcbf7b74fcf82d710cdda3fa24fb90707f8d55ccb36ba7465e4e862aef9b

Contents?: true

Size: 846 Bytes

Versions: 3

Compression:

Stored size: 846 Bytes

Contents

module ModelLog
  module ClassMethods
    module Controllers
      def self.included(base)
        base.class_eval do
          extend Invoking
          model_log_user_setting
        end
      end

      module Invoking
        def model_log_user_setting
          before_action :set_current_passport
          before_action :set_current_request
        end
      end

      private

        def set_current_passport
          ModelLog::Passport.clear_current_passport!
          ModelLog::Passport.current_passport = send(ModelLog.current_user_method)
        end

        def set_current_request
          ModelLog::Request.clear_current_request!
          ModelLog::Request.current_request = request
        end
    end
  end
end

ActionController::Base.send(:include, ModelLog::ClassMethods::Controllers) if defined? ActionController::Base

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
model_log-1.0.2 lib/model_log/class_methods/controllers.rb
model_log-1.0.1 lib/model_log/class_methods/controllers.rb
model_log-1.0.0 lib/model_log/class_methods/controllers.rb