Sha256: 56aad3fea448815ccf85f015dee6f8b9fee9ec77c4a06ea9465b9d535b865df2

Contents?: true

Size: 798 Bytes

Versions: 21

Compression:

Stored size: 798 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; end

      def create?() ;  false; end

      def manage?() ;  false; end
    end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

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