Class: Lookbook::HookStore

Inherits:
Object
  • Object
show all
Defined in:
lib/lookbook/stores/hook_store.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#storeObject (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