module Sequel::Plugins::SubsetConditions

  1. lib/sequel/plugins/subset_conditions.rb

The subset_conditions plugin creates an additional *_conditions method for every subset created, which returns the filter conditions the subset uses. This can be useful if you want to use the conditions for a separate filter or combine them with OR.


# Add subset_conditions in the Album class
Album.plugin :subset_conditions

# This will now create a published_conditions method
Album.dataset_module do
  subset :published, published: true

# SELECT * FROM albums WHERE (published IS TRUE)

# SELECT * FROM albums WHERE (published IS NOT TRUE)

Album.where(Album.published_conditions | {ready: true}).sql
# SELECT * FROM albums WHERE ((published IS TRUE) OR (ready IS TRUE))


Public Class

  1. apply

Included modules

  1. DatasetModuleMethods

Public Class methods

apply (mod, &block)
[show source]
   # File lib/sequel/plugins/subset_conditions.rb
29 def self.apply(mod, &block)
30   mod.instance_exec do
31     @dataset_module_class = do
32       include DatasetModuleMethods
33     end
34   end
35 end