Sha256: 4a19eed397ea2c8758753b947b589fa9ca5862550ea2d55487faaf60746982d3

Contents?: true

Size: 625 Bytes

Versions: 1

Compression:

Stored size: 625 Bytes

Contents

# frozen_string_literal: true

module IIPolicy
  module Coactors
    extend ActiveSupport::Concern

    included do
      include Coactive::Base

      configure_coactive do |config|
        config.load_paths = ['app/policies']
        config.class_suffix = 'Policy'
        config.use_cache = true
        config.lookup_superclass_until = ['ActiveRecord::Base', 'ActiveModel::Base']
      end

      class << self
        alias_method :chain, :coact
      end
    end

    def call(action)
      coactors.each do |policy|
        return false unless policy.new(@context).call(action)
      end
      super
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ii_policy-2.0.0 lib/ii_policy/coactors.rb