Class: RubyHooks::Hook
- Inherits:
-
Object
- Object
- RubyHooks::Hook
- Includes:
- Observable, Extensible
- Defined in:
- lib/ruby-hooks/hook.rb
Overview
Wrapper for Observable module
Instance Method Summary collapse
-
#changed_and_notify(*args) ⇒ nil|false
convienience method to set changed state and notify observers in one call.
-
#initialize(options = {}) ⇒ Hook
constructor
automatically extends Hook instance with given modules.
-
#observers ⇒ Array
allow writign code independent of the internals of Observable.
Methods included from Extensible
Constructor Details
#initialize(options = {}) ⇒ Hook
automatically extends Hook instance with given modules
19 20 21 22 23 |
# File 'lib/ruby-hooks/hook.rb', line 19 def initialize( = {}) @options = @observer_peers = {} add_plugins( :extend, [:extends]) end |
Instance Method Details
#changed_and_notify(*args) ⇒ nil|false
convienience method to set changed state and notify observers in one call
36 37 38 39 |
# File 'lib/ruby-hooks/hook.rb', line 36 def changed_and_notify(*args) changed notify_observers(*args) end |
#observers ⇒ Array
allow writign code independent of the internals of Observable
28 29 30 |
# File 'lib/ruby-hooks/hook.rb', line 28 def observers @observer_peers end |