Class Test::Unit::Util::ProcWrapper
In: lib/test/unit/util/procwrapper.rb
Parent: Object

Allows the storage of a Proc passed through ’&’ in a hash.

Note: this may be inefficient, since the hash being used is not necessarily very good. In Observable, efficiency is not too important, since the hash is only accessed when adding and removing listeners, not when notifying.

Methods

==   eql?   hash   new   to_proc  

Public Class methods

Creates a new wrapper for a_proc.

[Source]

    # File lib/test/unit/util/procwrapper.rb, line 23
23:         def initialize(a_proc)
24:           @a_proc = a_proc
25:           @hash = a_proc.inspect.sub(/^(#<#{a_proc.class}:)/){''}.sub(/(>)$/){''}.hex
26:         end

Public Instance methods

[Source]

    # File lib/test/unit/util/procwrapper.rb, line 32
32:         def ==(other)
33:           case(other)
34:             when ProcWrapper
35:               return @a_proc == other.to_proc
36:             else
37:               return super
38:           end
39:         end
eql?(other)

Alias for #==

[Source]

    # File lib/test/unit/util/procwrapper.rb, line 28
28:         def hash
29:           return @hash
30:         end

[Source]

    # File lib/test/unit/util/procwrapper.rb, line 42
42:         def to_proc
43:           return @a_proc
44:         end

[Validate]