Sha256: 6ad898c7014abbd032b812a6085541e093b17d84739fd6778bfa23233565668f

Contents?: true

Size: 786 Bytes

Versions: 6

Compression:

Stored size: 786 Bytes

Contents

module CanTango
  class Ability
    module RoleHelpers

      include CanTango::Helpers::RoleMethods

      # return list roles the user has
      def roles
        raise "#{subject.inspect} should have a #{roles_list_meth} method" if !subject.respond_to?(roles_list_meth)
        subj_roles = subject.send(roles_list_meth)
        return [] if subj_roles.blank?
        subj_roles.flatten
      end

      # return list of symbols for role groups the user belongs to
      def role_groups
        raise "#{subject.inspect} should have a #{role_groups_list_meth} method" if !subject.respond_to?(role_groups_list_meth)
        subj_role_groups = subject.send(role_groups_list_meth)
       return [] if subj_role_groups.blank?
        subj_role_groups.flatten
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
cantango-0.8.8 lib/cantango/ability/role_helpers.rb
cantango-0.8.7 lib/cantango/ability/role_helpers.rb
cantango-0.8.6.2 lib/cantango/ability/role_helpers.rb
cantango-0.8.6.1 lib/cantango/ability/role_helpers.rb
cantango-0.8.6 lib/cantango/ability/role_helpers.rb
cantango-0.8.5.1 lib/cantango/ability/role_helpers.rb