Method: Mongoid::Relations::Builders::ClassMethods#builder
- Defined in:
- lib/mongoid/relations/builders.rb
#builder(name, metadata) ⇒ Class
Defines a builder method for an embeds_one relation. This is defined as #build_name.
65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/mongoid/relations/builders.rb', line 65 def builder(name, ) re_define_method("build_#{name}") do |*args| attributes, = parse_args(*args) document = Factory.build(.klass, attributes, ) _building do child = send("#{name}=", document) child.run_callbacks(:build) child end end self end |