Sha256: 262c2ed23e2698365aada5b043a333e47838ba201f69645a1c3328f77ef50c19

Contents?: true

Size: 509 Bytes

Versions: 1

Compression:

Stored size: 509 Bytes

Contents

#
module RoleBasedSecurity
  module ModelAdditions
    # ::Rails.logger.error("...")

    #
    # Parameter role is a string rather than object, for example moderator or admin
    def has_role?(role)
      user_roles = UserRole.find :all, :conditions => ["user_id = ? ", self.id]
      return false if user_roles.nil? || (user_roles.size() == 0)
      user_roles.each do |user_role|
        next if user_role.role.code != role
        return true
      end
      false
    end



  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
role_based_security-0.5.0 lib/role_based_security/model_additions.rb