Class Tap::Signal
In: lib/tap/signal.rb
Parent: Object

Signal attaches an object and allows a specific method to be triggered through a standard interface.

Methods

Attributes

block  [R]  An optional block, used at the signal‘s discretion (normally passed to the method the signal targets on obj).
desc  [RW]  A description of self
obj  [R]  The object receiving signals through self.

Public Class methods

[Source]

    # File lib/tap/signal.rb, line 19
19:     def initialize(obj, &block)
20:       @obj = obj
21:       @block = block
22:     end

Public Instance methods

Calls process with the input args and returns the result.

[Source]

    # File lib/tap/signal.rb, line 25
25:     def call(args)
26:       process(args)
27:     end

[Source]

    # File lib/tap/signal.rb, line 34
34:     def inspect
35:       "#<#{self.class}:#{object_id}>"
36:     end

Simply returns the input args.

[Source]

    # File lib/tap/signal.rb, line 30
30:     def process(args)
31:       args
32:     end

Protected Instance methods

[Source]

    # File lib/tap/signal.rb, line 40
40:     def convert_to_array(obj, signature=[], options=false)
41:       return obj if obj.kind_of?(Array)
42:     
43:       argv = signature.collect {|key| obj[key] }
44:     
45:       if options
46:         opts = {}
47:         (obj.keys - signature).each do |key|
48:           opts[key] = obj[key]
49:         end
50:       
51:         argv << opts
52:       end
53:     
54:       argv
55:     end

[Source]

    # File lib/tap/signal.rb, line 57
57:     def convert_to_hash(obj, signature=[], remainder=nil)
58:       return obj if obj.kind_of?(Hash)
59:     
60:       args, argh = obj, {}
61:       signature.each do |key|
62:         argh[key] = args.shift
63:       end
64:     
65:       if remainder
66:         argh[remainder] = args
67:       end
68:     
69:       argh
70:     end

[Validate]