Class: Factory::Attribute::Dynamic

Inherits:
Factory::Attribute show all
Defined in:
lib/factory_girl/attribute/dynamic.rb

Overview

:nodoc:

Instance Attribute Summary

Attributes inherited from Factory::Attribute

#name

Instance Method Summary collapse

Constructor Details

#initialize(name, block) ⇒ Dynamic

Returns a new instance of Dynamic.



5
6
7
8
# File 'lib/factory_girl/attribute/dynamic.rb', line 5

def initialize(name, block)
  super(name)
  @block = block
end

Instance Method Details

#add_to(proxy) ⇒ Object



10
11
12
13
14
15
16
# File 'lib/factory_girl/attribute/dynamic.rb', line 10

def add_to(proxy)
  value = @block.arity.zero? ? @block.call : @block.call(proxy)
  if Factory::Sequence === value
    raise SequenceAbuseError
  end
  proxy.set(name, value)
end