Module: Sequel::Plugins::InstanceHooks

Defined in:
lib/sequel/plugins/instance_hooks.rb

Overview

The instance_hooks plugin allows you to add hooks to specific instances, by passing a block to a _hook method (e.g. before_save_hookdo_something). The block is executed when the hook is called (e.g. before_save).

All of the standard hooks are supported, except for after_initialize. Instance level before hooks are executed in reverse order of addition before calling super. Instance level after hooks are executed in order of addition after calling super. If any of the instance level before hook blocks return false, no more instance level before hooks are called and false is returned.

Instance level hooks are cleared when the object is saved successfully.

Usage:

# Add the instance hook methods to all model subclass instances (called before loading subclasses)
Sequel::Model.plugin :instance_hooks

# Add the instance hook methods just to Album instances
Album.plugin :instance_hooks

Defined Under Namespace

Modules: InstanceMethods