This repository has been archived by the owner on Aug 15, 2018. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
made first steps towards the ACL system, with can_publish? and can_po…
…st? methods on users
- Loading branch information
Josh Adams
committed
Nov 16, 2008
1 parent
b9bc59e
commit d46412f
Showing
8 changed files
with
43 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
module Ansuz | ||
module AclRoles | ||
STATIC_CAN_POST_ROLES = %w(admin author) | ||
STATIC_CAN_PUBLISH_ROLES = %w(admin final_reviewer) | ||
|
||
def can_post? | ||
can_do_thing? :post | ||
end | ||
|
||
def can_publish? | ||
can_do_thing? :publish | ||
end | ||
|
||
def can_do_thing? thing | ||
roles = case thing | ||
when :publish | ||
STATIC_CAN_PUBLISH_ROLES | ||
when :post | ||
STATIC_CAN_POST_ROLES | ||
end | ||
acceptable_roles = roles.select do |role| | ||
self.has_role?(role) | ||
end | ||
acceptable_roles.any? | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters