Sha256: 0bb148e05506fb5249a2137e3f3a503e61ca3322f6868756026e971e078c42a5

Contents?: true

Size: 780 Bytes

Versions: 22

Compression:

Stored size: 780 Bytes

Contents

# frozen_string_literal: true

module ActionPolicy
  module Policy
    # Create default rules and aliases:
    # - `index?` (=`false`)
    # - `create?` (=`false`)
    # - `new?` as an alias for `create?`
    # - `manage?` as a fallback for all unspecified rules (default rule)
    module Defaults
      def self.included(base)
        raise "Aliases support is required for defaults" unless
          base.ancestors.include?(Aliases)

        base.default_rule :manage?
        base.alias_rule :new?, to: :create?

        raise "Verification context support is required for defaults" unless
          base.ancestors.include?(Aliases)

        base.authorize :user
      end

      def index?() = false

      def create?() = false

      def manage?() = false
    end
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
action_policy-0.7.3 lib/action_policy/policy/defaults.rb
action_policy-0.7.2 lib/action_policy/policy/defaults.rb
action_policy-0.7.1 lib/action_policy/policy/defaults.rb
action_policy-0.7.0 lib/action_policy/policy/defaults.rb
action_policy-0.6.9 lib/action_policy/policy/defaults.rb
action_policy-0.6.8 lib/action_policy/policy/defaults.rb
action_policy-0.6.7 lib/action_policy/policy/defaults.rb
action_policy-0.6.6 lib/action_policy/policy/defaults.rb
action_policy-0.6.5 lib/action_policy/policy/defaults.rb
action_policy-0.6.4 lib/action_policy/policy/defaults.rb
action_policy-0.6.3 lib/action_policy/policy/defaults.rb
action_policy-0.6.2 lib/action_policy/policy/defaults.rb
action_policy-0.6.1 lib/action_policy/policy/defaults.rb
action_policy-0.6.0 lib/action_policy/policy/defaults.rb
action_policy-0.5.7 lib/action_policy/policy/defaults.rb
action_policy-0.5.6 lib/action_policy/policy/defaults.rb
action_policy-0.5.5 lib/action_policy/policy/defaults.rb
action_policy-0.5.4 lib/action_policy/policy/defaults.rb
action_policy-0.5.3 lib/action_policy/policy/defaults.rb
action_policy-0.5.2 lib/action_policy/policy/defaults.rb