Sha256: cce85c78331cb9f26d786bc48b0309e5ccb9f387fb2b8bd9d7e86dbd659a68d7

Contents?: true

Size: 1.29 KB

Versions: 58

Compression:

Stored size: 1.29 KB

Contents

# frozen-string-literal: true

module Sequel
  extension 'async_thread_pool'

  module Plugins
    # The async_thread_pool plugin makes it slightly easier to use the async_thread_pool
    # Database extension with models.  It makes Model.async return an async dataset for the
    # model, and support async behavior for #destroy, #with_pk, and #with_pk! for model
    # datasets:
    #
    #   # Will load the artist with primary key 1 asynchronously
    #   artist = Artist.async.with_pk(1)
    #
    # You must load the async_thread_pool Database extension into the Database object the
    # model class uses in order for async behavior to work.
    #
    # Usage:
    #
    #   # Make all model subclass datasets support support async class methods and additional
    #   # async dataset methods
    #   Sequel::Model.plugin :async_thread_pool
    #
    #   # Make the Album class support async class method and additional async dataset methods
    #   Album.plugin :async_thread_pool
    module AsyncThreadPool
      module ClassMethods
        Plugins.def_dataset_methods(self, :async)
      end

      module DatasetMethods
        [:destroy, :with_pk, :with_pk!].each do |meth|
          ::Sequel::Database::AsyncThreadPool::DatasetMethods.define_async_method(self, meth)
        end
      end
    end
  end
end

Version data entries

58 entries across 55 versions & 2 rubygems

Version Path
sequel-5.70.0 lib/sequel/plugins/async_thread_pool.rb
sequel-5.69.0 lib/sequel/plugins/async_thread_pool.rb
sequel-5.68.0 lib/sequel/plugins/async_thread_pool.rb
sequel-5.67.0 lib/sequel/plugins/async_thread_pool.rb
sequel-5.66.0 lib/sequel/plugins/async_thread_pool.rb
sequel-5.65.0 lib/sequel/plugins/async_thread_pool.rb
sequel-5.64.0 lib/sequel/plugins/async_thread_pool.rb
sequel-5.63.0 lib/sequel/plugins/async_thread_pool.rb
tdiary-5.2.4 vendor/bundle/ruby/3.1.0/gems/sequel-5.62.0/lib/sequel/plugins/async_thread_pool.rb
sequel-5.62.0 lib/sequel/plugins/async_thread_pool.rb
sequel-5.61.0 lib/sequel/plugins/async_thread_pool.rb
sequel-5.60.1 lib/sequel/plugins/async_thread_pool.rb
sequel-5.60.0 lib/sequel/plugins/async_thread_pool.rb
tdiary-5.2.3 vendor/bundle/ruby/3.1.0/gems/sequel-5.59.0/lib/sequel/plugins/async_thread_pool.rb
sequel-5.59.0 lib/sequel/plugins/async_thread_pool.rb
sequel-5.58.0 lib/sequel/plugins/async_thread_pool.rb
sequel-5.57.0 lib/sequel/plugins/async_thread_pool.rb
tdiary-5.2.2 vendor/bundle/ruby/3.1.0/gems/sequel-5.56.0/lib/sequel/plugins/async_thread_pool.rb
sequel-5.56.0 lib/sequel/plugins/async_thread_pool.rb
sequel-5.55.0 lib/sequel/plugins/async_thread_pool.rb