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
Jason Morrison e8ce6b9f26 Fixing the first Ruby 1.9 problem with calling a block that has an arity of zero or one
Signed-off-by: Nick Quaranto <nick@quaran.to>
2009-06-16 20:13:58 -04:00

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