Class: Factory::Attribute::Dynamic
- Inherits:
-
Factory::Attribute
- Object
- Factory::Attribute
- Factory::Attribute::Dynamic
- Defined in:
- lib/factory_girl/attribute/dynamic.rb
Overview
:nodoc:
Instance Attribute Summary
Attributes inherited from Factory::Attribute
Instance Method Summary collapse
- #add_to(proxy) ⇒ Object
-
#initialize(name, block) ⇒ Dynamic
constructor
A new instance of Dynamic.
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 |