Class: Caboose::Role
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Caboose::Role
- Defined in:
- app/models/caboose/role.rb
Constant Summary collapse
- ADMIN_ROLE_ID =
1
- LOGGED_OUT_ROLE_ID =
2
- LOGGED_IN_ROLE_ID =
3
Instance Attribute Summary collapse
-
#children ⇒ Object
Returns the value of attribute children.
Class Method Summary collapse
-
.roles_with_user(user_id) ⇒ Object
—————————————————————————– Class methods —————————————————————————–.
- .tree ⇒ Object
Instance Method Summary collapse
Instance Attribute Details
#children ⇒ Object
Returns the value of attribute children.
9 10 11 |
# File 'app/models/caboose/role.rb', line 9 def children @children end |
Class Method Details
.roles_with_user(user_id) ⇒ Object
Class methods
42 43 44 |
# File 'app/models/caboose/role.rb', line 42 def self.roles_with_user(user_id) return self.where("users.id" => user_id).all(:include => :users) end |
.tree ⇒ Object
46 47 48 |
# File 'app/models/caboose/role.rb', line 46 def self.tree return self.where(:parent_id => -1).reorder("name").all end |
Instance Method Details
#is_allowed(resource, action) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'app/models/caboose/role.rb', line 15 def is_allowed(resource, action) # Check for the admin permission for perm in return true if (perm.resource == "all" && perm.action == "all") end if (resource.is_a?(Caboose::Page)) for perm in return true if (perm.page_id == resource.id && perm.action == action) end elsif for perm in return true if (perm.resource == resource && perm.action == action) end end return false end |