module Sequel::Plugins

Empty namespace that plugins should use to store themselves, so they can be loaded via Model.plugin.

Plugins should be modules with one of the following conditions:

Public Class Methods

after_set_dataset(mod, meth) click to toggle source

Add method to mod that overrides set_dataset to call the method afterward.

Calls superclass method
   # File lib/sequel/model/plugins.rb
46 def self.after_set_dataset(mod, meth)
47   mod.send(:define_method, :set_dataset) do |*a|
48     r = super(*a)
49     # Allow calling private class methods as methods this specifies are usually private
50     send(meth)
51     r
52   end
53 end
def_dataset_methods(mod, meths) click to toggle source

In the given module mod, define methods that are call the same method on the dataset. This is designed for plugins to define dataset methods inside ClassMethods that call the implementations in DatasetMethods.

This should not be called with untrusted input or method names that can't be used literally, since it uses class_eval.

   # File lib/sequel/model/plugins.rb
31 def self.def_dataset_methods(mod, meths)
32   Array(meths).each do |meth|
33     mod.class_eval("def #{meth}(*args, &block); dataset.#{meth}(*args, &block) end", __FILE__, __LINE__)
34   end
35 end
inherited_instance_variables(mod, hash) click to toggle source

Add method to mod that overrides inherited_instance_variables to include the values in this hash.

Calls superclass method
   # File lib/sequel/model/plugins.rb
39 def self.inherited_instance_variables(mod, hash)
40   mod.send(:define_method, :inherited_instance_variables) do ||
41     super().merge!(hash)
42   end
43 end