Class: Test::Unit::Fixture::HookPoint
- Inherits:
-
Object
- Object
- Test::Unit::Fixture::HookPoint
- Defined in:
- lib/test/unit/fixture.rb
Instance Method Summary collapse
- #after_callbacks ⇒ Object
- #before_callbacks ⇒ Object
-
#initialize(default_options) ⇒ HookPoint
constructor
A new instance of HookPoint.
- #register(method_name_or_callback, options = nil) ⇒ Object
- #unregister(method_name_or_callback) ⇒ Object
Constructor Details
#initialize(default_options) ⇒ HookPoint
Returns a new instance of HookPoint.
71 72 73 74 75 76 |
# File 'lib/test/unit/fixture.rb', line 71 def initialize() @default_options = @before_callbacks = [] @after_callbacks = [] @unregistered_callbacks = [] end |
Instance Method Details
#after_callbacks ⇒ Object
111 112 113 |
# File 'lib/test/unit/fixture.rb', line 111 def after_callbacks @after_callbacks - @unregistered_callbacks end |
#before_callbacks ⇒ Object
107 108 109 |
# File 'lib/test/unit/fixture.rb', line 107 def before_callbacks @before_callbacks - @unregistered_callbacks end |
#register(method_name_or_callback, options = nil) ⇒ Object
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/test/unit/fixture.rb', line 78 def register(method_name_or_callback, =nil) ||= {} unless () = "must be {:before => :prepend}, " + "{:before => :append}, {:after => :prepend} or " + "{:after => :append}: #{.inspect}" raise ArgumentError, end if .empty? = @default_options end before_how = [:before] after_how = [:after] if before_how @before_callbacks = add_callback(@before_callbacks, method_name_or_callback, before_how) else @after_callbacks = add_callback(@after_callbacks, method_name_or_callback, after_how) end end |
#unregister(method_name_or_callback) ⇒ Object
103 104 105 |
# File 'lib/test/unit/fixture.rb', line 103 def unregister(method_name_or_callback) @unregistered_callbacks << method_name_or_callback end |