| Path: | doc/release_notes/4.28.0.txt |
| Last Update: | Sat Jun 02 02:04:22 +0000 2018 |
class Foo < Sequel::Model
plugin :subset_conditions
subset :active, :active=>true
end
Foo.exclude(Foo.active_conditions)
Foo.where(:a=>1).or(Foo.active_conditions)
# Assume boolean column :active Foo.plugin :boolean_subsets Foo.active # SELECT * FROM foos WHERE (active IS TRUE)
You can provide a block to the plugin to change the arguments passed to subset:
Foo.plugin :boolean_subsets do |column|
[:"where_#{column}", column]
end
Foo.where_active
# SELECT * FROM foos WHERE active
As with similar plugins, you can add the boolean_subsets plugin to Sequel::Model itself, and all subclasses created afterward will have the boolean subset methods automatically created.