모듈: Mongoid::Clients::Options
- 확장자:
- ActiveSupport::Concern
- 포함 항목:
- Mongoid::Clients, Mongoid::Criteria
- 다음에 정의됨:
- lib/mongoid/clients/options.rb
개요
Mongoid::Document에 포함된 Mixin 모듈은 지속성 및 쿼리 작업을 위한 데이터베이스 컨텍스트를 관리 수 있는 기능 을 제공합니다. 예를 예시, 여기에는 문서를 다른 컬렉션에 저장하고 세컨더리 인스턴스에서 문서를 읽는 것이 포함됩니다.
네임스페이스 아래에 정의됨
모듈: 클래스 메서드
인스턴스 메서드 요약 접기
-
#컬렉션(parent = nil) ⇒ Mongo::Collection
문서의 현재 지속성 컨텍스트에 대한 컬렉션 가져옵니다.
-
#collection_name ⇒ string
문서의 현재 지속성 컨텍스트에 대한 컬렉션 이름을 가져옵니다.
-
#mongo_client ⇒ Mongo::Client
문서의 현재 지속성 컨텍스트에 대한 데이터베이스 클라이언트 가져옵니다.
-
#persistence_context ⇒ Mongoid::PersistenceContext
문서의 현재 지속성 컨텍스트를 가져옵니다.
-
#persistence_context? ⇒ true | false
문서 또는 문서의 클래스에 대해 지속성 컨텍스트가 설정하다 있는지 여부를 반환합니다.
-
#with(options_or_context) ⇒ 객체
차단 하는 동안 이 객체 에 대한 지속성 컨텍스트를 변경합니다.
인스턴스 메서드 세부 정보
#컬렉션(parent = nil) ⇒ Mongo::Collection
문서의 현재 지속성 컨텍스트에 대한 컬렉션 가져옵니다.
45 46 47 |
# 파일 'lib/mongoid/clients/options.rb', 줄 45 def 컬렉션(부모 = nil) persistence_context.컬렉션(부모) end |
#collection_name ⇒ string
문서의 현재 지속성 컨텍스트에 대한 컬렉션 이름을 가져옵니다.
56 57 58 |
# 파일 'lib/mongoid/clients/options.rb', 줄 56 def collection_name persistence_context.collection_name end |
#mongo_client ⇒ Mongo::Client
문서의 현재 지속성 컨텍스트에 대한 데이터베이스 클라이언트 가져옵니다.
67 68 69 |
# 파일 'lib/mongoid/clients/options.rb', 줄 67 def mongo_client persistence_context.고객 end |
#persistence_context ⇒ Mongoid::PersistenceContext
참고:
내장된 문서의 경우 루트 상위 문서 의 지속성 컨텍스트가 반환됩니다.
문서의 현재 지속성 컨텍스트를 가져옵니다.
81 82 83 84 85 86 87 88 89 |
# 파일 'lib/mongoid/clients/options.rb', 줄 81 def persistence_context 만약 && !_root? _root.persistence_context other PersistenceContext.get(self) || PersistenceContext.get(self.클래스) || PersistenceContext.신규(self.클래스, ) end end |
#persistence_context? ⇒ true | false
참고:
내장된 문서의 경우 루트 상위 문서 의 지속성 컨텍스트가 사용됩니다.
문서 또는 문서의 클래스에 대해 지속성 컨텍스트가 설정하다 있는지 여부를 반환합니다.
101 102 103 104 105 106 107 108 109 |
# 파일 'lib/mongoid/clients/options.rb', 줄 101 def persistence_context? 만약 && !_root? _root.persistence_context? other &.어떤? || PersistenceContext.get(self).현재? || PersistenceContext.get(self.클래스).현재? end end |
#with(options_or_context) ⇒ 객체
차단 하는 동안 이 객체 에 대한 지속성 컨텍스트를 변경합니다.
26 27 28 29 30 31 32 33 |
# 파일 'lib/mongoid/clients/options.rb', 줄 26 def 와() original_context = PersistenceContext.get(self) original_cluster = persistence_context.cluster set_persistence_context() yield self 보장 clear_persistence_context(original_cluster, original_context) end |