Class: Casbin::Effect::DefaultEffector
- Defined in:
- lib/casbin-ruby/effect/default_effector.rb
Overview
default effector for Casbin.
Constant Summary
Constants inherited from Effector
Effector::ALLOW, Effector::DENY, Effector::INDETERMINATE
Class Method Summary collapse
- .effect_to_bool(effect) ⇒ Object
-
.get_effector(expr) ⇒ Object
creates an effector based on the current policy effect expression.
Methods inherited from Effector
#final_effect, #intermediate_effect
Class Method Details
.effect_to_bool(effect) ⇒ Object
29 30 31 32 33 34 |
# File 'lib/casbin-ruby/effect/default_effector.rb', line 29 def self.effect_to_bool(effect) return true if effect == ALLOW return false if effect == DENY raise "effect can't be converted to boolean" end |
.get_effector(expr) ⇒ Object
creates an effector based on the current policy effect expression
14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/casbin-ruby/effect/default_effector.rb', line 14 def self.get_effector(expr) case expr when 'some(where (p_eft == allow))' Effect::AllowOverrideEffector.new when '!some(where (p_eft == deny))' Effect::DenyOverrideEffector.new when 'some(where (p_eft == allow)) && !some(where (p_eft == deny))' Effect::AllowAndDenyEffector.new when 'priority(p_eft) || deny' Effect::PriorityEffector.new else raise 'unsupported effect' end end |