Module Sequel::Plugins::HookClassMethods
In: lib/sequel/plugins/hook_class_methods.rb

Sequel‘s built-in hook class methods plugin is designed for backwards compatibility. Its use is not encouraged, it is recommended to use instance methods and super instead of this plugin. What this plugin allows you to do is, for example:

  # Block only, can cause duplicate hooks if code is reloaded
  before_save{self.created_at = Time.now}
  # Block with tag, safe for reloading
  before_save(:set_created_at){self.created_at = Time.now}
  # Tag only, safe for reloading, calls instance method
  before_save(:set_created_at)

Pretty much anything you can do with a hook class method, you can also do with an instance method instead:

   def before_save
     return false if super == false
     self.created_at = Time.now
   end

Methods

apply  

Classes and Modules

Module Sequel::Plugins::HookClassMethods::ClassMethods
Module Sequel::Plugins::HookClassMethods::InstanceMethods

Public Class methods

Set up the hooks instance variable in the model.

[Source]

    # File lib/sequel/plugins/hook_class_methods.rb, line 24
24:       def self.apply(model)
25:         hooks = model.instance_variable_set(:@hooks, {})
26:         Model::HOOKS.each{|h| hooks[h] = []}
27:       end

[Validate]