Module: Mongoid::Relations::Accessors

Defined in:
lib/custom_fields/extensions/mongoid/relations/accessors.rb

Instance Method Summary (collapse)

Instance Method Details

- (Proxy) build_with_custom_fields(name, object, metadata)

Builds the related document and creates the relation based on the class enhanced by the custom_fields functionnality (if set up for the relation).

Parameters:

  • name (String, Symbol)

    The name of the relation.

  • object (Hash, BSON::ObjectId)

    The id or attributes to use.

  • metadata (Metadata)

    The relation's metadata.

  • building (true, false)

    If we are in a build operation.

Returns:

  • (Proxy)

    The relation.

Since:

  • 2.0.0.rc.1



18
19
20
21
22
23
24
25
# File 'lib/custom_fields/extensions/mongoid/relations/accessors.rb', line 18

def build_with_custom_fields(name, object, )
  if self.respond_to?(:custom_fields_for?) && self.custom_fields_for?(.name)
    # puts "[Accessors] build_with_custom_fields #{name}"
     = self.()
  end

  build_without_custom_fields(name, object, )
end