Sha256: c7430ea9a4ff8c274f964ce394fd55c0e46b6b93d713616ffdc1c097079a2849

Contents?: true

Size: 1.07 KB

Versions: 7

Compression:

Stored size: 1.07 KB

Contents

# frozen_string_literal: true

require 'rails'
require 'active_support'
require 'request_store'

require 'phi_attrs/version'
require 'phi_attrs/configure'
require 'phi_attrs/railtie' if defined?(Rails)
require 'phi_attrs/formatter'
require 'phi_attrs/logger'
require 'phi_attrs/exceptions'
require 'phi_attrs/phi_record'

module PhiAttrs
  def self.log_phi_access(user, message)
    PhiAttrs::Logger.tagged(PHI_ACCESS_LOG_TAG, user) do
      PhiAttrs::Logger.info(message)
    end
  end

  module Model
    def phi_model(with: nil, except: nil)
      include PhiRecord
    end
  end

  module Controller
    extend ActiveSupport::Concern

    included do
      before_action :record_i18n_data
    end

    private

    def record_i18n_data
      RequestStore.store[:phi_attrs_controller] = self.class.name
      RequestStore.store[:phi_attrs_action] = params[:action]

      return if PhiAttrs.current_user_method.nil?
      return unless respond_to?(PhiAttrs.current_user_method, true)

      RequestStore.store[:phi_attrs_current_user] = send(PhiAttrs.current_user_method)
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
phi_attrs-0.3.2 lib/phi_attrs.rb
phi_attrs-0.3.1 lib/phi_attrs.rb
phi_attrs-0.3.0 lib/phi_attrs.rb
phi_attrs-0.2.4 lib/phi_attrs.rb
phi_attrs-0.2.2 lib/phi_attrs.rb
phi_attrs-0.2.1 lib/phi_attrs.rb
phi_attrs-0.2.0 lib/phi_attrs.rb