Sha256: 0dcb9e36cf0a1057782691f6a9e5da8e835d59cc557f52d29acc61ecd07bef7b
Contents?: true
Size: 682 Bytes
Versions: 1
Compression:
Stored size: 682 Bytes
Contents
= Hook Library Require the hook.rb library. require 'facets/hook' Build a class with signals. class X include Hook def course @course ||= [] end hook :signal def boom(event, message) course << "Kaboom!" end signal do |event, message| course << ["1", event, message] end signal do |event, message| course << ["2", event, message] end signal :boom end Triger the signal. x = X.new x.signal("hi") The hooks should have been fired. x.course[0].should == ["1", :signal, "hi"] x.course[1].should == ["2", :signal, "hi"] x.course[2].should == "Kaboom!" x.course[3].should == nil QED.
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
facets-2.7.0 | demo/hook.rd |