lib/reuser/role.rb in reuser-0.2.2 vs lib/reuser/role.rb in reuser-1.0.0

- old
+ new

@@ -1,19 +1,16 @@ require_relative('../reuser') module ReUser class Role - attr_reader :actions - def initialize(name) + @name = name @actions = {} end def can(*names) - names.each do |name| - action(name) - end + actions(*names) end def can?(name) actions[name] end @@ -23,10 +20,16 @@ action(name, test) end end def could?(name, data) - @actions[name] == Proc ? @actions[name].call(data) : true + if actions[name] + if actions[name].is_a?(Proc) + actions[name].call(data) + else + true + end + end end private def actions(*names) names.each do |name|