Sha256: 39e2f87335776f61760ac1359d7a948ef9cf9eca42bd9e5ad8046ed21562b535

Contents?: true

Size: 829 Bytes

Versions: 16

Compression:

Stored size: 829 Bytes

Contents

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

16 entries across 16 versions & 1 rubygems

Version Path
alchemy_cms-3.6.7 lib/alchemy/ability_helper.rb
alchemy_cms-3.6.6 lib/alchemy/ability_helper.rb
alchemy_cms-3.6.5 lib/alchemy/ability_helper.rb
alchemy_cms-3.6.4 lib/alchemy/ability_helper.rb
alchemy_cms-3.6.3 lib/alchemy/ability_helper.rb
alchemy_cms-3.6.2 lib/alchemy/ability_helper.rb
alchemy_cms-3.6.1 lib/alchemy/ability_helper.rb
alchemy_cms-4.0.0.beta lib/alchemy/ability_helper.rb
alchemy_cms-3.6.0 lib/alchemy/ability_helper.rb
alchemy_cms-3.5.0 lib/alchemy/ability_helper.rb
alchemy_cms-3.4.2 lib/alchemy/ability_helper.rb
alchemy_cms-3.5.0.rc2 lib/alchemy/ability_helper.rb
alchemy_cms-3.5.0.rc1 lib/alchemy/ability_helper.rb
alchemy_cms-3.4.1 lib/alchemy/ability_helper.rb
alchemy_cms-3.4.0 lib/alchemy/ability_helper.rb
alchemy_cms-3.4.0.rc1 lib/alchemy/ability_helper.rb