Module: SimpleCan::BasicStrategy
Constant Summary collapse
- ROLES =
%w(read write manage).freeze
- REV_ROLES =
ROLES.map.with_index.to_h.freeze
Instance Method Summary collapse
- #fail(_role, _name) ⇒ Object
- #roles ⇒ Object
- #test(role, capability) ⇒ Object
- #to_capability(role) ⇒ Object
Instance Method Details
#fail(_role, _name) ⇒ Object
17 18 19 |
# File 'lib/simple_can/basic_strategy.rb', line 17 def fail(_role, _name) :unauthorized end |
#roles ⇒ Object
13 14 15 |
# File 'lib/simple_can/basic_strategy.rb', line 13 def roles ROLES end |
#test(role, capability) ⇒ Object
8 9 10 11 |
# File 'lib/simple_can/basic_strategy.rb', line 8 def test(role, capability) capability = 0 if capability.nil? capability >= to_capability(role) end |
#to_capability(role) ⇒ Object
21 22 23 24 |
# File 'lib/simple_can/basic_strategy.rb', line 21 def to_capability(role) return if role.nil? REV_ROLES[role] end |