Search code examples
rubysequel

Ruby sequel equivalent to ActiveRecord none


I'm looking for a way to replicate the behavior of none in Sequel. So far I haven't been able to find a way to create a dataset, or a dataset like thing, without tying it to a table.

At the moment I am just returning an enum but I would like to preserve the dataset API to not break any chaining.

E.g.

class User < Sequel::Model
end

User.none  # => instance of dataset

Solution

  • Sequel has a null_dataset extension for this: http://sequel.jeremyevans.net/rdoc-plugins/files/lib/sequel/extensions/null_dataset_rb.html