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
-
#initialize(name, ignored, block) ⇒ Dynamic
constructor
A new instance of Dynamic.
- #to_proc ⇒ Object
Methods inherited from FactoryGirl::Attribute
Constructor Details
#initialize(name, ignored, block) ⇒ Dynamic
Returns a new instance of Dynamic.
4 5 6 7 |
# File 'lib/factory_girl/attribute/dynamic.rb', line 4 def initialize(name, ignored, block) super(name, ignored) @block = block end |
Instance Method Details
#to_proc ⇒ Object
9 10 11 12 13 14 15 16 17 |
# File 'lib/factory_girl/attribute/dynamic.rb', line 9 def to_proc block = @block lambda { value = block.arity == 1 ? block.call(self) : instance_exec(&block) raise SequenceAbuseError if FactoryGirl::Sequence === value value } end |