Class: Factory::Proxy

Inherits:
Object
  • Object
show all
Defined in:
lib/factory_girl/proxy.rb,
lib/factory_girl/proxy/stub.rb,
lib/factory_girl/proxy/build.rb,
lib/factory_girl/proxy/create.rb,
lib/factory_girl/proxy/attributes_for.rb

Overview

:nodoc:

Direct Known Subclasses

AttributesFor, Build, Stub

Defined Under Namespace

Classes: AttributesFor, Build, Create, Stub

Instance Method Summary collapse

Constructor Details

#initialize(klass) ⇒ Proxy

Returns a new instance of Proxy.



4
5
# File 'lib/factory_girl/proxy.rb', line 4

def initialize(klass)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, &block) ⇒ Object



53
54
55
# File 'lib/factory_girl/proxy.rb', line 53

def method_missing(method, *args, &block)
  get(method)
end

Instance Method Details

#associate(name, factory, attributes) ⇒ Object



14
15
# File 'lib/factory_girl/proxy.rb', line 14

def associate(name, factory, attributes)
end

#association(name, overrides = {}) ⇒ Object

Generates an association using the current build strategy.

Arguments:

name: (Symbol)
  The name of the factory that should be used to generate this
  association.
attributes: (Hash)
  A hash of attributes that should be overridden for this association.

Returns:

The generated association for the current build strategy. Note that
assocaitions are not generated for the attributes_for strategy. Returns
nil in this case.

Example:

Factory.define :user do |f|
  # ...
end

Factory.define :post do |f|
  # ...
  f.author {|a| a.association :user, :name => 'Joe' }
end

# Builds (but doesn't save) a Post and a User
Factory.build(:post)

# Builds and saves a User, builds a Post, assigns the User to the 
# author association, and saves the User.
Factory.create(:post)


49
50
51
# File 'lib/factory_girl/proxy.rb', line 49

def association(name, overrides = {})
  nil
end

#get(attribute) ⇒ Object



7
8
9
# File 'lib/factory_girl/proxy.rb', line 7

def get(attribute)
  nil
end

#resultObject

Raises:

  • (NotImplementedError)


57
58
59
# File 'lib/factory_girl/proxy.rb', line 57

def result
  raise NotImplementedError, "Strategies must return a result"
end

#set(attribute, value) ⇒ Object



11
12
# File 'lib/factory_girl/proxy.rb', line 11

def set(attribute, value)
end