mirror of
https://github.com/thoughtbot/factory_bot.git
synced 2022-11-09 11:43:51 -05:00
e8ce6b9f26
Signed-off-by: Nick Quaranto <nick@quaran.to>
20 lines
410 B
Ruby
20 lines
410 B
Ruby
class Factory
|
|
class Attribute #:nodoc:
|
|
|
|
class Dynamic < Attribute #:nodoc:
|
|
def initialize(name, block)
|
|
super(name)
|
|
@block = block
|
|
end
|
|
|
|
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
|
|
end
|
|
|
|
end
|
|
end
|