1
0
Fork 0
mirror of https://github.com/thoughtbot/factory_bot.git synced 2022-11-09 11:43:51 -05:00
thoughtbot--factory_bot/lib/factory_girl/attribute/dynamic.rb

21 lines
410 B
Ruby
Raw Normal View History

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