Class: Lookbook::HookStore
- Inherits:
-
Object
- Object
- Lookbook::HookStore
- Defined in:
- lib/lookbook/stores/hook_store.rb
Constant Summary collapse
- CONFIG_FILE =
"config/hooks.yml"
Instance Attribute Summary collapse
-
#store ⇒ Object
readonly
Returns the value of attribute store.
Class Method Summary collapse
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.
8 9 10 |
# File 'lib/lookbook/stores/hook_store.rb', line 8 def initialize(config = nil) @store = {} end |
Instance Attribute Details
#store ⇒ Object (readonly)
Returns the value of attribute store.
5 6 7 |
# File 'lib/lookbook/stores/hook_store.rb', line 5 def store @store end |
Class Method Details
.default_config ⇒ Object
24 25 26 |
# File 'lib/lookbook/stores/hook_store.rb', line 24 def self.default_config ConfigLoader.call(CONFIG_FILE) end |
.init_from_config ⇒ Object
20 21 22 |
# File 'lib/lookbook/stores/hook_store.rb', line 20 def self.init_from_config new(default_config) end |
Instance Method Details
#add_hook(event_name, callback) ⇒ Object
12 13 14 |
# File 'lib/lookbook/stores/hook_store.rb', line 12 def add_hook(event_name, callback) for_event(event_name) << callback end |
#for_event(event_name) ⇒ Object
16 17 18 |
# File 'lib/lookbook/stores/hook_store.rb', line 16 def for_event(event_name) store[event_name.to_sym] ||= [] end |