123456789_123456789_123456789_123456789_123456789_

Module: Mongoid::Clients::StorageOptions

Relationships & Source Files
Namespace Children
Modules:
Extension / Inclusion / Inheritance Descendants
Included In:
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
self, ActiveSupport::Concern
Defined in: lib/mongoid/clients/storage_options.rb

Overview

Mixin module included into ::Mongoid::Document which adds the ability to set the collection in which to store the document by default.

Instance Attribute Summary

Instance Method Summary

  • #remember_storage_options! Internal use only Internal use only

    Saves the storage options from the current persistence context.

  • #storage_options ⇒ Hash Internal use only Internal use only

    The storage options that apply to this record, consisting of both the class-level declared storage options (e.g.

DSL Calls

included

[ GitHub ]


13
14
15
# File 'lib/mongoid/clients/storage_options.rb', line 13

included do
  class_attribute :storage_options, instance_accessor: false, default: storage_options_defaults
end

Instance Attribute Details

#remembered_storage_optionsHash | nil (rw)

This method is for internal use only.

Remembers the storage options that were active when the current object was instantiated/created.

Returns:

  • (Hash | nil)

    the storage options that have been cached for this object instance (or nil if no storage options have been cached).

[ GitHub ]

  
# File 'lib/mongoid/clients/storage_options.rb', line 25

attr_accessor :remembered_storage_options

Instance Method Details

#remember_storage_options!

This method is for internal use only.

Saves the storage options from the current persistence context.

[ GitHub ]

  
# File 'lib/mongoid/clients/storage_options.rb', line 41

def remember_storage_options!
  return if Mongoid.legacy_persistence_context_behavior

  opts = persistence_context.requested_storage_options
  self.remembered_storage_options = opts if opts
end

#storage_optionsHash

This method is for internal use only.

The storage options that apply to this record, consisting of both the class-level declared storage options (e.g. store_in) merged with any remembered storage options.

Returns:

  • (Hash)

    the storage options for the record

[ GitHub ]

  
# File 'lib/mongoid/clients/storage_options.rb', line 34

def storage_options
  self.class.storage_options.merge(remembered_storage_options || {})
end