클래스: Mongoid::Association::Nested::Many
- 상속:
-
객체
- 객체
- Mongoid::Association::Nested::Many
- 다음을 포함합니다.
- Buildable
- 다음에 정의됨:
- lib/mongoid/association/nested/many.rb
개요
many-to-n 연관 관계에 #accepts_nested_attributes_for 속성 할당을 수행하는 데 사용되는 빌더 클래스입니다.
인스턴스 속성 요약
Buildable에 포함된 속성
#association, #attributes, #existing, #options
인스턴스 메서드 요약 접기
-
#빌드(parent, options = {}) ⇒ 배열
매크로에 전달된 속성과 옵션에 따라 연관 관계를 구축합니다.
-
#initialize(association, attributes, options = {}) ⇒ Many
생성자
일대다 연결에서 중첩된 속성에 대한 새 빌더를 만듭니다.
Buildable에 포함된 메서드
#allow_destory?, #convert_id, #reject?, #update_only?
생성자 세부 정보
#initialize(association, attributes, options = {}) ⇒ Many
일대다 연결에서 중첩된 속성에 대한 새 빌더를 만듭니다.
55 56 57 58 59 60 61 62 63 64 65 66 |
# 파일 'lib/mongoid/association/nested/many.rb', 줄 55 def 초기화(연관 관계, 속성, = {}) @attributes = 만약 속성.response_to?(:with_in Different_access) 속성.with_in Different_access.sort do |a, b| a[0].to_i <=> b[0].to_i end other 속성 end @association = 연관 관계 @options = @class_name = [:class_name] ? [:class_name].상수화 : 연관 관계.class end |
인스턴스 메서드 세부 정보
#빌드(parent, options = {}) ⇒ 배열
매크로에 전달된 속성과 옵션에 따라 연관 관계를 구축합니다.
이는 기존 연결의 업데이트, 연결을 새 문서로 교체 또는 연결 제거 중 하나인 3 작업을 수행하려고 시도합니다.
속성이 해시 또는 키/값 쌍의 배열이 아닌 경우 인수 오류가 발생합니다.
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# 파일 'lib/mongoid/association/nested/many.rb', 줄 28 def 빌드(부모, = {}) @existing = 부모.send(연관 관계.이름) 올리다 오류::TooManyNestedAttributeRecords.신규(기존, [:limit]) 만약 over_limit?(속성) 속성.각 do |attrs| 만약 attrs.is_a?(::해시) process_attributes(부모, attrs.with_in Different_access) elsif attrs.is_a?(배열) && attrs.분량 > 1 && attrs[1].response_to?(:with_in Different_access) process_attributes(부모, attrs[1].with_in Different_access) elsif attrs.is_a?(배열) && attrs.분량.심지어? process_attributes(부모, 해시[*attrs].with_in Different_access) other 올리다 ArgumentError, "중첩된 연관 관계의 속성' #{association.name} '은(는) 해시 또는 키/값 쌍의 배열이어야 합니다." end end end |