Sha256: 72d75db7e891cae31ac602254bf1f6077caa4e631c36b18bdcf72cf1654dfbf2

Contents?: true

Size: 860 Bytes

Versions: 178

Compression:

Stored size: 860 Bytes

Contents

# frozen_string_literal: true

module Alchemy::AbilityHelper
  # Ensures usage of Alchemy's permissions class.
  #
  # == Register custom Abilities
  #
  # If your app has a CanCan Ability class with rules you want to be aviable in an Alchemy context
  # you need to register it. Or if you have an engine with it's own CanCan abilities you want to
  # add to Alchemy you must register them first.
  #
  #     Alchemy.register_ability MyCustom::Permisson
  #
  def current_ability
    @current_ability ||= begin
      alchemy_permissions = Alchemy::Permissions.new(current_alchemy_user)
      Alchemy.registered_abilities.each do |klass|
        # Ensure to avoid issues with Rails constant lookup.
        klass = "::#{klass}".constantize
        alchemy_permissions.merge(klass.new(current_alchemy_user))
      end
      alchemy_permissions
    end
  end
end

Version data entries

178 entries across 178 versions & 1 rubygems

Version Path
alchemy_cms-7.3.5 lib/alchemy/ability_helper.rb
alchemy_cms-7.2.8 lib/alchemy/ability_helper.rb
alchemy_cms-7.1.13 lib/alchemy/ability_helper.rb
alchemy_cms-7.0.16 lib/alchemy/ability_helper.rb
alchemy_cms-7.3.4 lib/alchemy/ability_helper.rb
alchemy_cms-7.3.3 lib/alchemy/ability_helper.rb
alchemy_cms-7.3.2 lib/alchemy/ability_helper.rb
alchemy_cms-7.2.7 lib/alchemy/ability_helper.rb
alchemy_cms-7.3.1 lib/alchemy/ability_helper.rb
alchemy_cms-7.3.0 lib/alchemy/ability_helper.rb
alchemy_cms-7.2.6 lib/alchemy/ability_helper.rb
alchemy_cms-7.2.5 lib/alchemy/ability_helper.rb
alchemy_cms-7.1.12 lib/alchemy/ability_helper.rb
alchemy_cms-7.0.15 lib/alchemy/ability_helper.rb
alchemy_cms-6.1.10 lib/alchemy/ability_helper.rb
alchemy_cms-7.2.4 lib/alchemy/ability_helper.rb
alchemy_cms-7.1.11 lib/alchemy/ability_helper.rb
alchemy_cms-7.2.3 lib/alchemy/ability_helper.rb
alchemy_cms-7.1.10 lib/alchemy/ability_helper.rb
alchemy_cms-7.2.2 lib/alchemy/ability_helper.rb