Class: FactoryGirl::Attribute::Dynamic
- Inherits:
-
FactoryGirl::Attribute
- Object
- FactoryGirl::Attribute
- FactoryGirl::Attribute::Dynamic
- Defined in:
- lib/factory_girl/attribute/dynamic.rb
Overview
:nodoc:
Instance Attribute Summary
Attributes inherited from FactoryGirl::Attribute
Instance Method Summary collapse
- #add_to(proxy) ⇒ Object
-
#initialize(name, block) ⇒ Dynamic
constructor
A new instance of Dynamic.
Methods inherited from FactoryGirl::Attribute
#<=>, #association?, #priority
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 == 1 ? @block.call(proxy) : proxy.instance_exec(&@block) if FactoryGirl::Sequence === value raise SequenceAbuseError end proxy.set(name, value) end |