module Sequel::Plugins::DefDatasetMethod

  1. lib/sequel/plugins/def_dataset_method.rb

The def_dataset_method plugin adds Model.def_dataset_method for defining dataset methods:

Album.def_dataset_method(:by_name) do |name|
  where(name: name)

Additionally, this adds support for Model.subset, which can also be used to define dataset methods that add specific filters:

Album.subset(:gold){copies_sold >= 500000}

This exists for backwards compatibility with previous Sequel versions.


# Make all model subclasses support Model.def_dataset_method
# (called before loading subclasses)
Sequel::Model.plugin :def_dataset_method

# Make the Album class support Model.def_dataset_method
Album.plugin :def_dataset_method