Module: Bridgetown::Builders::DSL::Hooks
- Included in:
- PluginBuilder
- Defined in:
- lib/bridgetown-builder/dsl/hooks.rb
Instance Method Summary collapse
- #add_data(data_key) ⇒ Object
- #hook(owner, event, method_name = nil, priority: Bridgetown::Hooks::DEFAULT_PRIORITY, &block) ⇒ Object
Instance Method Details
#add_data(data_key) ⇒ Object
20 21 22 23 24 |
# File 'lib/bridgetown-builder/dsl/hooks.rb', line 20 def add_data(data_key) hook(:site, :post_read) do site.data[data_key] = yield end end |
#hook(owner, event, method_name = nil, priority: Bridgetown::Hooks::DEFAULT_PRIORITY, &block) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/bridgetown-builder/dsl/hooks.rb', line 7 def hook( owner, event, method_name = nil, priority: Bridgetown::Hooks::DEFAULT_PRIORITY, &block ) block = method(method_name) if method_name.is_a?(Symbol) hook_block = Bridgetown::Hooks.register_one(owner, event, priority: priority, &block) functions << { name: name, hook: [owner, event, priority, hook_block] } end |