Class: Lookbook::HookStore
- Inherits:
-
Object
- Object
- Lookbook::HookStore
- Defined in:
- lib/lookbook/stores/hook_store.rb
Instance Attribute Summary collapse
- #store ⇒ Object readonly
Instance Method Summary collapse
- #add_hook(event_name, callback) ⇒ Object
- #for_event(event_name) ⇒ Object
-
#initialize(config = nil) ⇒ HookStore
constructor
A new instance of HookStore.
Constructor Details
#initialize(config = nil) ⇒ HookStore
Returns a new instance of HookStore.
6 7 8 |
# File 'lib/lookbook/stores/hook_store.rb', line 6 def initialize(config = nil) @store = {} end |
Instance Attribute Details
#store ⇒ Object (readonly)
3 4 5 |
# File 'lib/lookbook/stores/hook_store.rb', line 3 def store @store end |
Instance Method Details
#add_hook(event_name, callback) ⇒ Object
10 11 12 |
# File 'lib/lookbook/stores/hook_store.rb', line 10 def add_hook(event_name, callback) for_event(event_name) << callback end |
#for_event(event_name) ⇒ Object
14 15 16 |
# File 'lib/lookbook/stores/hook_store.rb', line 14 def for_event(event_name) store[event_name.to_sym] ||= [] end |