Module: Sequel::Plugins::DefDatasetMethod

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

Overview

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)
end

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.

Usage:

# 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

Defined Under Namespace

Modules: ClassMethods