lib/ostiary/policy.rb in ostiary-0.9.0 vs lib/ostiary/policy.rb in ostiary-0.10.0

- old
+ new

@@ -1,19 +1,21 @@ module Ostiary class Policy - attr_accessor :name, :rules + attr_reader :name, :method, :actions - def initialize(name, rules = []) - @name = name - @rules = rules || [] + def initialize(name, actions = [], method: nil) + @name = name + @method = method + @actions = actions end def inspect "#{name}" end - def met?(*) - yield + def met?(_action) + return yield name unless method + method.call end def error_message(action) "#{action} requires #{name}" end