Sha256: 6aa5a2d1c584ce58fee83233483820210e383c2e835e7cf208a06b4647af9133

Contents?: true

Size: 849 Bytes

Versions: 19

Compression:

Stored size: 849 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

      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

19 entries across 19 versions & 1 rubygems

Version Path
rocketjob-6.3.1 lib/rocket_job/extensions/mongoid/clients/options.rb
rocketjob-6.3.0 lib/rocket_job/extensions/mongoid/clients/options.rb
rocketjob-6.2.0 lib/rocket_job/extensions/mongoid/clients/options.rb
rocketjob-6.1.1 lib/rocket_job/extensions/mongoid/clients/options.rb
rocketjob-6.1.0 lib/rocket_job/extensions/mongoid/clients/options.rb
rocketjob-6.0.3 lib/rocket_job/extensions/mongoid/clients/options.rb
rocketjob-6.0.2 lib/rocket_job/extensions/mongoid/clients/options.rb
rocketjob-6.0.1 lib/rocket_job/extensions/mongoid/clients/options.rb
rocketjob-6.0.0 lib/rocket_job/extensions/mongoid/clients/options.rb
rocketjob-6.0.0.rc3 lib/rocket_job/extensions/mongoid/clients/options.rb
rocketjob-6.0.0.rc2 lib/rocket_job/extensions/mongoid/clients/options.rb
rocketjob-6.0.0.rc1 lib/rocket_job/extensions/mongoid/clients/options.rb
rocketjob-5.4.1 lib/rocket_job/extensions/mongoid/clients/options.rb
rocketjob-5.4.0 lib/rocket_job/extensions/mongoid/clients/options.rb
rocketjob-5.4.0.beta2 lib/rocket_job/extensions/mongoid/clients/options.rb
rocketjob-5.4.0.beta1 lib/rocket_job/extensions/mongoid/clients/options.rb
rocketjob-5.3.3 lib/rocket_job/extensions/mongoid/clients/options.rb
rocketjob-5.3.2 lib/rocket_job/extensions/mongoid/clients/options.rb
rocketjob-5.3.1 lib/rocket_job/extensions/mongoid/clients/options.rb