Sha256: 4bd23efc82f9c15c86c3df9b1da2a735af4e4788aeec2491cc2c62a7c50ac97f

Contents?: true

Size: 1.32 KB

Versions: 21

Compression:

Stored size: 1.32 KB

Contents

# frozen-string-literal: true

module Sequel
  class Dataset
    # This module implements methods to support deprecated use of extensions registered
    # not using a module.  In such cases, for backwards compatibility, Sequel has to use
    # a singleton class for the dataset.
    module DeprecatedSingletonClassMethods
      # Load the extension into a clone of the receiver.
      def extension(*a)
        c = _clone(:freeze=>false)
        c.send(:_extension!, a)
        c.freeze
      end

      # Extend the cloned of the receiver with the given modules, instead of the default
      # approach of creating a subclass of the receiver's class and including the modules
      # into that.
      def with_extend(*mods, &block)
        c = _clone(:freeze=>false)
        c.extend(*mods) unless mods.empty?
        c.extend(DatasetModule.new(&block)) if block
        c.freeze
      end

      private

      # Load the extensions into the receiver.
      def _extension!(exts)
        Sequel.extension(*exts)
        exts.each do |ext|
          if pr = Sequel.synchronize{EXTENSIONS[ext]}
            pr.call(self)
          else
            raise(Error, "Extension #{ext} does not have specific support handling individual datasets (try: Sequel.extension #{ext.inspect})")
          end
        end
        self
      end
    end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
sequel-5.86.0 lib/sequel/dataset/deprecated_singleton_class_methods.rb
sequel-5.85.0 lib/sequel/dataset/deprecated_singleton_class_methods.rb
sequel-5.84.0 lib/sequel/dataset/deprecated_singleton_class_methods.rb
sequel-5.83.1 lib/sequel/dataset/deprecated_singleton_class_methods.rb
sequel-5.83.0 lib/sequel/dataset/deprecated_singleton_class_methods.rb
sequel-5.82.0 lib/sequel/dataset/deprecated_singleton_class_methods.rb
sequel-5.81.0 lib/sequel/dataset/deprecated_singleton_class_methods.rb
sequel-5.80.0 lib/sequel/dataset/deprecated_singleton_class_methods.rb
sequel-5.79.0 lib/sequel/dataset/deprecated_singleton_class_methods.rb
sequel-5.78.0 lib/sequel/dataset/deprecated_singleton_class_methods.rb
sequel-5.77.0 lib/sequel/dataset/deprecated_singleton_class_methods.rb
sequel-5.76.0 lib/sequel/dataset/deprecated_singleton_class_methods.rb
sequel-5.75.0 lib/sequel/dataset/deprecated_singleton_class_methods.rb
sequel-5.74.0 lib/sequel/dataset/deprecated_singleton_class_methods.rb
sequel-5.73.0 lib/sequel/dataset/deprecated_singleton_class_methods.rb
sequel-5.72.0 lib/sequel/dataset/deprecated_singleton_class_methods.rb
sequel-5.71.0 lib/sequel/dataset/deprecated_singleton_class_methods.rb
sequel-5.70.0 lib/sequel/dataset/deprecated_singleton_class_methods.rb
sequel-5.69.0 lib/sequel/dataset/deprecated_singleton_class_methods.rb
sequel-5.68.0 lib/sequel/dataset/deprecated_singleton_class_methods.rb