Class: RailsDrips::PolicyDecision
- Inherits:
-
Object
- Object
- RailsDrips::PolicyDecision
- Defined in:
- app/services/rails_drips/policy_decision.rb
Defined Under Namespace
Classes: Decision
Class Method Summary collapse
Class Method Details
.allowed?(value) ⇒ Boolean
17 18 19 |
# File 'app/services/rails_drips/policy_decision.rb', line 17 def self.allowed?(value) call(value).allowed end |
.call(value) ⇒ Object
7 8 9 10 11 12 13 14 15 |
# File 'app/services/rails_drips/policy_decision.rb', line 7 def self.call(value) return Decision.new(allowed: value) if value == true || value == false value = value.to_h.transform_keys(&:to_sym) Decision.new( allowed: value.fetch(:allowed, value.fetch(:eligible, false)), reason: value[:reason] ) end |