class Sequel::Model::DatasetModule
This Module subclass is used by Model.dataset_module to add dataset methods to classes. It adds a couple of features standard Modules, allowing you to use the same subset method you can call on Model, as well as making sure that public methods added to the module automatically have class methods created for them.
Public Class Methods
def_dataset_caching_method(mod, meth)
click to toggle source
Define a method in the module
# File lib/sequel/model/dataset_module.rb, line 48 def self.def_dataset_caching_method(mod, meth) mod.send(:define_method, meth) do |name, *args, &block| if block @model.def_dataset_method(name){send(meth, *args, &block)} else key = :"_#{meth}_#{name}_ds" @model.def_dataset_method(name) do cached_dataset(key){send(meth, *args)} end end end end
new(model)
click to toggle source
Store the model related to this dataset module.
# File lib/sequel/model/dataset_module.rb, line 13 def initialize(model) @model = model end
Public Instance Methods
subset(name, *args, &block)
click to toggle source
Define a named filter for this dataset, see Model.subset for details.
# File lib/sequel/model/dataset_module.rb, line 19 def subset(name, *args, &block) @model.subset(name, *args, &block) end
where(name, *args, &block)
click to toggle source
Alias for subset
# File lib/sequel/model/dataset_module.rb, line 24 def where(name, *args, &block) subset(name, *args, &block) end
Private Instance Methods
method_added(meth)
click to toggle source
Add a class method to the related model that calls the dataset method of the same name.
# File lib/sequel/model/dataset_module.rb, line 69 def method_added(meth) @model.send(:def_model_dataset_method, meth) end