Sha256: 80e10848fe383fbe4c2f1a344ec96ca7609481fef0fe035e16a7eefef8ed0751
Contents?: true
Size: 706 Bytes
Versions: 6
Compression:
Stored size: 706 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. --- require 'ae/should'
Version data entries
6 entries across 6 versions & 1 rubygems
Version | Path |
---|---|
facets-2.9.2 | work/trash/hook.rdoc |
facets-2.8.4 | demo/hook.rdoc |
facets-2.8.3 | demo/hook.rdoc |
facets-2.8.2 | demo/hook.rdoc |
facets-2.8.1 | demo/hook.rdoc |
facets-2.8.0 | demo/hook.rdoc |