模块:Mongoid::Clients::StorageOptions

扩展方式:
ActiveSupport::Concern
包含在:
Mongoid::Clients
定义于:
lib/mongoid/clients/storage_options.rb

Overview

Mongoid::Document 中包含的 Mixin 模块能力了设立默认存储文档的集合的功能。

在命名空间下定义

模块: 类方法

实例属性摘要折叠

实例方法摘要折叠

实例属性详细信息

#membered_storage_options哈希 | nil

此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。

记住实例化/创建当前对象时处于活动状态的存储选项。

返回:

  • ( Hash | nil )

    已为此对象实例缓存的存储选项(如果没有缓存任何存储选项,则为 nil)。



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

def membered_storage_options
  @remembered_storage_options
end

实例方法详细信息

#记住存储选项!对象

此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。

保存当前持久性上下文中的存储选项。



41
42
43
44
45
46
# File 'lib/mongoid/clients/storage_options.rb', line 41

def keep_storage_options!
  return if Mongoid.legacy_persistence_context_behavior

  opts = persistence_context.requests_storage_options
  self.membered_storage_options = opts if opts
end

# storage_options哈希

此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。

应用此记录的存储选项,由类级别声明的存储选项(例如 store_in)与任何记住的存储选项合并。

返回:

  • (哈希)

    记录的存储选项



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

def storage_options
  self.class.storage_options.合并(merge)(membered_storage_options || {})
end