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

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

Instance Method Summary collapse

Instance Method Details

#freezeObject

Freeze hooks when freezing model class.


50
51
52
53
# File 'lib/sequel/plugins/hook_class_methods.rb', line 50

def freeze
  @hooks.freeze.each_value(&:freeze)
  super
end

#has_hooks?(hook) ⇒ Boolean

Returns true if there are any hook blocks for the given hook.

Returns:

  • (Boolean)

56
57
58
# File 'lib/sequel/plugins/hook_class_methods.rb', line 56

def has_hooks?(hook)
  !@hooks[hook].empty?
end

#hook_blocks(hook) ⇒ Object

Yield every block related to the given hook.


61
62
63
# File 'lib/sequel/plugins/hook_class_methods.rb', line 61

def hook_blocks(hook)
  @hooks[hook].each{|k,v| yield v}
end