Sha256: fa47c8aa9654cb4d293427c4a2e584de6c0727897f01953a3d13f7587c8414ba

Contents?: true

Size: 971 Bytes

Versions: 13

Compression:

Stored size: 971 Bytes

Contents

# frozen-string-literal: true

module Sequel
  class Model
    # 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.
    class DatasetModule < ::Module
      # Store the model related to this dataset module.
      def initialize(model)
        @model = model
      end

      # Define a named filter for this dataset, see
      # Model.subset for details.
      def subset(name, *args, &block)
        @model.subset(name, *args, &block)
      end

      private

      # Add a class method to the related model that
      # calls the dataset method of the same name.
      def method_added(meth)
        @model.send(:def_model_dataset_method, meth)
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 2 rubygems

Version Path
sequel-4.41.0 lib/sequel/model/dataset_module.rb
sequel-4.40.0 lib/sequel/model/dataset_module.rb
sequel-4.39.0 lib/sequel/model/dataset_module.rb
tdiary-5.0.2 vendor/bundle/gems/sequel-4.37.0/lib/sequel/model/dataset_module.rb
sequel-4.38.0 lib/sequel/model/dataset_module.rb
sequel-4.37.0 lib/sequel/model/dataset_module.rb
sequel-4.36.0 lib/sequel/model/dataset_module.rb
tdiary-5.0.1 vendor/bundle/gems/sequel-4.35.0/lib/sequel/model/dataset_module.rb
sequel-4.35.0 lib/sequel/model/dataset_module.rb
sequel-4.34.0 lib/sequel/model/dataset_module.rb
sequel-4.33.0 lib/sequel/model/dataset_module.rb
sequel-4.32.0 lib/sequel/model/dataset_module.rb
sequel-4.31.0 lib/sequel/model/dataset_module.rb