Module: Sequel::Plugins::ChewyObserve
- Extended by:
- Chewy::Type::Observe::Helpers
- Defined in:
- lib/sequel/plugins/chewy_observe.rb
Overview
This Sequel plugin adds support for chewy's model-observing hook for updating indexes after model save or destroy.
Usage:
# Make all model subclasses support the update_index
hook (called
# before loading subclasses).
Sequel::Model.plugin :chewy_observe
# Make the Album class support the update_index
hooks.
Album.plugin :chewy_observe
# Declare one or more update_index
observers in model.
class Album < Sequel::Model
update_index('albums#album') { self }
end
Defined Under Namespace
Modules: ClassMethods, InstanceMethods
Class Method Summary collapse
Methods included from Chewy::Type::Observe::Helpers
extract_callback_options!, update_proc
Class Method Details
.apply(model) ⇒ Object
25 26 27 28 29 30 |
# File 'lib/sequel/plugins/chewy_observe.rb', line 25 def self.apply(model) model.instance_eval do include ActiveSupport::Callbacks define_callbacks :commit, :destroy_commit, :save, :destroy end end |