Sha256: a241f29f138e42287d6b12ea5eacc1eba56bd67a223b3ea8ce3ec489ad226b44

Contents?: true

Size: 970 Bytes

Versions: 130

Compression:

Stored size: 970 Bytes

Contents

# frozen_string_literal: true

module Spree
  module PermissionSets
    # This is the base class used for crafting permission sets.
    #
    # This is used by {Spree::RoleConfiguration} when adding custom behavior to {Spree::Ability}.
    # See one of the subclasses for example structure such as {Spree::PermissionSets::UserDisplay}
    #
    # @see Spree::RoleConfiguration
    # @see Spree::PermissionSets
    class Base
      # @param ability [CanCan::Ability]
      #   The ability that will be extended with the current permission set.
      #   The ability passed in must respond to #user
      def initialize(ability)
        @ability = ability
      end

      # Activate permissions on the ability. Put your can and cannot statements here.
      # Must be overriden by subclasses
      def activate!
        raise NotImplementedError.new
      end

      private

      attr_reader :ability
      delegate :can, :cannot, :user, to: :ability
    end
  end
end

Version data entries

130 entries across 130 versions & 2 rubygems

Version Path
solidus_core-3.4.4 lib/spree/permission_sets/base.rb
solidus_core-3.3.4 lib/spree/permission_sets/base.rb
solidus_core-3.2.9 lib/spree/permission_sets/base.rb
solidus_core-3.2.8 lib/spree/permission_sets/base.rb
solidus_core-3.3.3 lib/spree/permission_sets/base.rb
solidus_core-3.4.3 lib/spree/permission_sets/base.rb
solidus_core-4.0.1 lib/spree/permission_sets/base.rb
solidus_core-4.1.0 lib/spree/permission_sets/base.rb
solidus_core-4.0.0 lib/spree/permission_sets/base.rb
solidus_core-3.4.2 lib/spree/permission_sets/base.rb
solidus_core-3.2.7 lib/spree/permission_sets/base.rb
solidus_core-3.3.2 lib/spree/permission_sets/base.rb
solidus_core-3.4.1 lib/spree/permission_sets/base.rb
solidus_core-3.4.0 lib/spree/permission_sets/base.rb
solidus_core-3.3.1 lib/spree/permission_sets/base.rb
solidus_core-3.2.6 lib/spree/permission_sets/base.rb
solidus_core-3.1.9 lib/spree/permission_sets/base.rb
solidus_core-3.3.0 lib/spree/permission_sets/base.rb
solidus_core-3.2.5 lib/spree/permission_sets/base.rb
solidus_core-3.2.4 lib/spree/permission_sets/base.rb