Sha256: 440a93fa1acfa5aa2a4295bb11283fe9ccd01995286eeb278e80e2c9f7f69fff

Contents?: true

Size: 1.27 KB

Versions: 15

Compression:

Stored size: 1.27 KB

Contents

# Wrap lms specific CanCan rules.  Should be included in the main app's
# Ability class.
# NOTE:  When checking abilities, don't check for Class level abilities,
# unless you don't care about the instance level.  For example, don't
# use both styles
#   can? :moderate, Forum
#   can? :moderate, @forum
# In this case, if you need to check the class level, then use specific
#    current_user.has_role? :moderator, Forum
#------------------------------------------------------------------------------

module DmNewsletter
  module Concerns
    module Ability
      def dm_newsletter_abilities(user)
        #--- Admin
        if user && user.has_role?(:newsletter_manager)
          can :manage_newsletters, :all
          can :access_admin, :all
        end
      end

      ::Ability.register_abilities(:dm_newsletter_abilities)

    end
  end
end

#------------------------------------------------------------------------------
# The abilities get basically compiled.  So if you use
#
#    can :moderate, Forum, :id => Forum.with_role(:moderator, user).map(&:id)
#
# this will execute the Forum.with_role query once during Ability.new.  However
#
#    can :moderate, Forum do |forum|
#      user.has_role? :moderator, forum
#    end
#
# this will execute the has_role? block on each call to can?

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
dm_newsletter-4.2.3.10 app/models/dm_newsletter/concerns/ability.rb
dm_newsletter-4.2.3.9 app/models/dm_newsletter/concerns/ability.rb
dm_newsletter-4.2.3.8 app/models/dm_newsletter/concerns/ability.rb
dm_newsletter-4.2.3.7 app/models/dm_newsletter/concerns/ability.rb
dm_newsletter-4.2.3.6 app/models/dm_newsletter/concerns/ability.rb
dm_newsletter-4.2.3.5 app/models/dm_newsletter/concerns/ability.rb
dm_newsletter-4.2.3.4 app/models/dm_newsletter/concerns/ability.rb
dm_newsletter-4.2.3.3 app/models/dm_newsletter/concerns/ability.rb
dm_newsletter-4.2.3.2 app/models/dm_newsletter/concerns/ability.rb
dm_newsletter-4.2.3.1 app/models/dm_newsletter/concerns/ability.rb
dm_newsletter-4.2.3 app/models/dm_newsletter/concerns/ability.rb
dm_newsletter-4.2.2.3 app/models/dm_newsletter/concerns/ability.rb
dm_newsletter-4.2.2.2 app/models/dm_newsletter/concerns/ability.rb
dm_newsletter-4.2.2.1 app/models/dm_newsletter/concerns/ability.rb
dm_newsletter-4.2.2 app/models/dm_newsletter/concerns/ability.rb