module Mongoid::Relations::Builders

This module is responsible for defining the build and create methods used in one to one relations.

@example Methods that get created.

class Person
  include Mongoid::Document
  embeds_one :name
end

# The following methods get created:
person.build_name({ :first_name => "Durran" })
person.create_name({ :first_name => "Durran" })

@since 2.0.0.rc.1

Private Instance Methods

parse_args(*args) click to toggle source

Parse out the attributes and the options from the args passed to a build_ or create_ methods.

@example Parse the args.

doc.parse_args(:name => "Joe")

@param [ Array ] args The arguments.

@return [ Array<Hash> ] The attributes and options.

@since 2.3.4

# File lib/mongoid/relations/builders.rb, line 48
def parse_args(*args)
  [ args.first || {}, args.size > 1 ? args[1] : {} ]
end