클래스: Mongoid::Attributes::Projector Private

상속:
객체
  • 객체
모두 표시
다음에 정의됨:
lib/mongoid/attributes/projector.rb

개요

이 클래스는 비공개 API의 일부입니다. 이 클래스는 향후 제거되거나 변경될 수 있으므로 가능하면 사용하지 않는 것이 좋습니다.

이 모듈은 프로젝션 헬퍼를 정의합니다.

Projection rules are rather non-trivial. See https://www.mongodb.com/ko-kr/docs/manual/reference/method/db.collection.find/#find-projection for server documentation. 4.4 server (and presumably all older ones) requires that a projection for content fields is either exclusionary or inclusionary, i.e. one cannot mix exclusions and inclusions in the same query. However, _id can be excluded in a projection that includes content fields. Integer projection values other than 0 and 1 aren't officially documented as of this writing; see DOCSP-15266. 4.4 server also allows nested hash projection specification in addition to dot notation, which I assume Mongoid doesn't handle yet.

인스턴스 속성 요약 접기

인스턴스 메서드 요약 접기

생성자 세부 정보

#initialize(프로젝션) ⇒ Projector

이 메서드는 비공개 API의 일부입니다. 이 방법은 향후 제거되거나 변경될 수 있으므로 가능하면 사용하지 않는 것이 좋습니다.

프로젝터의 새 인스턴스를 반환합니다.



22
23
24
25
26
27
28
29
30
31
# 파일 'lib/mongoid/attributes/projector.rb', 줄 22

def 초기화(프로젝션)
  만약 프로젝션
    @content_projection = 프로젝션.dup
    @content_projection.삭제('_id')
    @id_projection_value = 프로젝션['_id']
  other
    @content_projection = nil
    @id_projection_value = nil
  end
end

인스턴스 속성 세부 정보

#Content_projection객체 (읽기 전용)

이 메서드는 비공개 API의 일부입니다. 이 방법은 향후 제거되거나 변경될 수 있으므로 가능하면 사용하지 않는 것이 좋습니다.



33
34
35
# 파일 'lib/mongoid/attributes/projector.rb', 줄 33

def Content_projection
  @content_projection
end

#id_projection_value객체 (읽기 전용)

이 메서드는 비공개 API의 일부입니다. 이 방법은 향후 제거되거나 변경될 수 있으므로 가능하면 사용하지 않는 것이 좋습니다.



33
34
35
# 파일 'lib/mongoid/attributes/projector.rb', 줄 33

def id_projection_value
  @id_projection_value
end

인스턴스 메서드 세부 정보

#attribute_or_path_allowed?(name) ⇒ true | false

이 메서드는 비공개 API의 일부입니다. 이 방법은 향후 제거되거나 변경될 수 있으므로 가능하면 사용하지 않는 것이 좋습니다.

지정된 속성 또는 점 표기법 경로가 구성된 프로젝션(있는 경우)에서 허용되는지 확인합니다.

구성된 프로젝션 이 없으면 true를 반환합니다.

매개변수:

  • 이름 (string)

    속성의 이름 또는 점 표기법 경로입니다.

반환합니다:

  • (true | false)

    프로젝션 에서 속성을 허용하는지 여부입니다.



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# 파일 'lib/mongoid/attributes/projector.rb', 줄 45

def attribute_or_path_allowed?(이름)
  # _id 에 대한 특수 처리.
  만약 이름 == '_id'
    결과 = id_projection_value.nil? || value_inclusionary?(id_projection_value)
    반환 결과
  end

  만약 Content_projection.nil?
    # 프로젝션 이 없습니다 ( 빈 프로젝션 과 반대).
    # 모든 속성이 허용됩니다.
    반환 true
  end

  # 요청된 이름/경로와 일치하거나 상위 항목인 항목을 찾습니다.
  # 이는 예를 예시 프로젝션 이 다음과 같은 경우를 처리합니다.
  # {foo: true}이고 foo.bar가 허용되는지 알고 싶습니다.
  item, value = Content_projection.감지 do |경로, _value|
    (이름 + '.').start_with?(경로 + '.')
  end
  반환 value_inclusionary?(value) 만약 item

  만약 Content_inclusionary?
    # 요청된 이름/경로의 엄격한 하위 항목을 찾습니다.
    # 이는 예를 예시 프로젝션 이 다음과 같은 경우를 처리합니다.
    # {"foo.bar" => true}이고 foo가 허용되는지 알고 싶습니다.
    # (바의 컨테이너 와 같습니다.)
    item, = Content_projection.감지 do |경로, _value|
      (경로 + '.').start_with?(이름 + '.')
    end
    반환 true 만약 item
  end

  !Content_inclusionary?
end