Class: Factory::Proxy::Stub

Inherits:
Factory::Proxy show all
Defined in:
lib/factory_girl/proxy/stub.rb

Overview

:nodoc:

Instance Method Summary collapse

Methods inherited from Factory::Proxy

#association, #method_missing

Constructor Details

#initialize(klass) ⇒ Stub

Returns a new instance of Stub.



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

def initialize(klass)
  @mock = Object.new
end

Dynamic Method Handling

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

Instance Method Details

#associate(name, factory, attributes) ⇒ Object



19
20
21
# File 'lib/factory_girl/proxy/stub.rb', line 19

def associate(name, factory, attributes)
  set(name, nil)
end

#get(attribute) ⇒ Object



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

def get(attribute)
  @mock.send(attribute)
end

#resultObject



23
24
25
# File 'lib/factory_girl/proxy/stub.rb', line 23

def result
  @mock      
end

#set(attribute, value) ⇒ Object



12
13
14
15
16
17
# File 'lib/factory_girl/proxy/stub.rb', line 12

def set(attribute, value)
  unless @mock.respond_to?("#{attribute}=")
    class << @mock; self end.send(:attr_accessor, attribute)
  end
  @mock.send("#{attribute}=", value)
end