Class: FactoryGirl::Proxy::Create

Inherits:
Build show all
Defined in:
lib/factory_girl/proxy/create.rb

Overview

:nodoc:

Instance Attribute Summary

Attributes inherited from FactoryGirl::Proxy

#callbacks

Instance Method Summary collapse

Methods inherited from Build

#associate, #association, #get, #initialize, #parse_method, #remove_method, #set

Methods inherited from FactoryGirl::Proxy

#add_callback, #associate, #association, #get, #initialize, #method_missing, #run_callbacks, #set, #set_ignored

Constructor Details

This class inherits a constructor from FactoryGirl::Proxy::Build

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class FactoryGirl::Proxy

Instance Method Details

#get_method(method_string) ⇒ Object



15
16
17
18
19
# File 'lib/factory_girl/proxy/create.rb', line 15

def get_method(method_string)
  # Leaving this as Proxy::Build in the :method => :build case
  # is a bit strange, but does it have any user-visible behaviors?
  parse_method(method_string)
end

#result(to_create) ⇒ Object



4
5
6
7
8
9
10
11
12
13
# File 'lib/factory_girl/proxy/create.rb', line 4

def result(to_create)
  run_callbacks(:after_build)
  if to_create
    to_create.call(@instance)
  else
    @instance.save!
  end
  run_callbacks(:after_create)
  @instance
end