Module: Perennial::Hookable

Included in:
Loader
Defined in:
lib/perennial/hookable.rb

Overview

Perennial::Hookable

Perennial::Hookable provides a generic set of functionality for implementing simple block-based hooks / callbacks. On a class level, this makes it easy for you to do event driven programming in that code can be registered to be run when something happens.

Hookable differs from Perennial::Dispatchable in that it is designed to be lightweight / used for things like setting things up without all of the overhead of defining handlers / dispatching messages.

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Class Method Details

.included(parent) ⇒ Object



16
17
18
19
20
21
22
# File 'lib/perennial/hookable.rb', line 16

def self.included(parent)
  parent.class_eval do
    extend ClassMethods
    cattr_accessor :hooks
    self.hooks = Hash.new { |h,k| h[k] = [] }
  end
end