Sha256: 02d27c6f1bd77e46f39b065fd84d598eb7cfe37ceab3d3261cfdcbdf0fb8a925
Contents?: true
Size: 542 Bytes
Versions: 2
Compression:
Stored size: 542 Bytes
Contents
module Ostiary class Ostiary attr_accessor :policies def initialize @policies = [] end def authorize!(action) policies.each do |policy| next if policy_met?(policy, action, &Proc.new) raise PolicyBroken, policy.error_message(action) end end def authorized?(action) policies.all? do |policy| policy_met?(policy, action, &Proc.new) end end private def policy_met?(policy, action) policy.met?(action) { yield(policy.name) } end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
ostiary-0.9.0 | lib/ostiary/ostiary.rb |
ostiary-0.8.0 | lib/ostiary/ostiary.rb |