module ReUser
  class Role
    def initialize name, permissions=[]
      @name = name
      @permissions = {}
      self.can *permissions
    end

    def can *permissions
      permissions.each do |permission|
        @permissions[permission] = lambda {|*args| true }
      end
    end

    def can? permission
      @permissions[permission].is_a? Proc
    end

    def could permission, &block
      raise "#could requires a block" unless block_given?
      @permissions[permission] = block
    end

    def could? permission, block_args
      @permissions[permission].call(block_args)
    end
  end
end

module ReUser
  class Role
    attr_reader :name

    def permissions
      @permissions.keys
    end

    def initialize name, permissions=[]
      @name = name
      @permissions = {}
      self.can *permissions
    end

    def can *permissions
      permissions.each do |permission|
        @permissions[permission] = lambda {|*args| true }
      end
    end

    def can? permission
      @permissions[permission].is_a? Proc
    end

    def could permission, &block
      raise "#could requires a block" unless block_given?
      @permissions[permission] = block
    end

    def could? permission, block_args
      @permissions[permission].call(block_args)
    end
  end
end

Revert "removed the accessors for ReUser::Role"
Revert "removed the accessors for ReUser::Role"

This reverts commit 81c81ae7741e48cf4f49676dabc3d9e2175f2f62.
