Sha256: ba4315afa9f6cc5591e10a895decd80d56ce5572d604d9e0f73a91e482f3c4fe

Contents?: true

Size: 864 Bytes

Versions: 14

Compression:

Stored size: 864 Bytes

Contents

require 'mongoid/criteria'
require 'mongoid/document'
module RocketJob
  module MongoidClients
    module Options
      extend ActiveSupport::Concern

      def with_collection(collection_name)
        self.collection_name = collection_name
        self
      end

      def collection(parent = nil)
        @collection_name ? mongo_client[@collection_name] : super(parent)
      end

      def collection_name
        @collection_name || super
      end

      def collection_name=(collection_name)
        @collection_name = collection_name&.to_sym
      end

      private

      module ClassMethods
        def with_collection(collection_name)
          all.with_collection(collection_name)
        end
      end
    end
  end
end

::Mongoid::Criteria.include(RocketJob::MongoidClients::Options)
::Mongoid::Document.include(RocketJob::MongoidClients::Options)

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
rocketjob-5.1.1 lib/rocket_job/extensions/mongoid/clients/options.rb
rocketjob-5.1.0 lib/rocket_job/extensions/mongoid/clients/options.rb
rocketjob-5.0.0 lib/rocket_job/extensions/mongoid/clients/options.rb
rocketjob-5.0.0.rc1 lib/rocket_job/extensions/mongoid/clients/options.rb
rocketjob-5.0.0.beta4 lib/rocket_job/extensions/mongoid/clients/options.rb
rocketjob-5.0.0.beta3 lib/rocket_job/extensions/mongoid/clients/options.rb
rocketjob-5.0.0.beta2 lib/rocket_job/extensions/mongoid/clients/options.rb
rocketjob-5.0.0.beta lib/rocket_job/extensions/mongoid/clients/options.rb
rocketjob-4.3.0.beta2 lib/rocket_job/extensions/mongoid/clients/options.rb
rocketjob-4.3.0.beta lib/rocket_job/extensions/mongoid/clients/options.rb
rocketjob-4.2.0 lib/rocket_job/extensions/mongoid/clients/options.rb
rocketjob-4.1.1 lib/rocket_job/extensions/mongoid/clients/options.rb
rocketjob-4.1.0 lib/rocket_job/extensions/mongoid/clients/options.rb
rocketjob-4.0.0 lib/rocket_job/extensions/mongoid/clients/options.rb