Class: Mongoid::Relations::Referenced::Many
- Inherits:
-
Relations::Many
- Object
- Relations::Many
- Mongoid::Relations::Referenced::Many
- Defined in:
- lib/custom_fields/extensions/mongoid/relations/referenced/many.rb
Overview
This class defines the behaviour for all relations that are a one-to-many between documents in different collections.
Instance Method Summary collapse
Instance Method Details
#build_with_custom_fields(attributes = {}, options = {}, type = nil) ⇒ Object Also known as: new
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/custom_fields/extensions/mongoid/relations/referenced/many.rb', line 10 def build_with_custom_fields(attributes = {}, = {}, type = nil) if base.respond_to?(:custom_fields_for?) && base.custom_fields_for?(.name) # all the information about how to build the custom class are stored here recipe = base.custom_fields_recipe_for(.name) attributes ||= {} attributes.merge!(custom_fields_recipe: recipe) # build the class with custom_fields for the first time type = .klass.klass_with_custom_fields(recipe) end build_without_custom_fields(attributes, , type) end |