class FactoryGirl::Callback
Constants
- VALID_NAMES
Attributes
block[R]
name[R]
Public Class Methods
new(name, block)
click to toggle source
# File lib/factory_girl/callback.rb, line 7 def initialize(name, block) @name = name.to_sym @block = block check_name end
Public Instance Methods
==(other)
click to toggle source
# File lib/factory_girl/callback.rb, line 21 def ==(other) name == other.name && block == other.block end
run(instance, proxy)
click to toggle source
# File lib/factory_girl/callback.rb, line 13 def run(instance, proxy) case block.arity when 1 then block.call(instance) when 2 then block.call(instance, proxy) else block.call end end
Private Instance Methods
check_name()
click to toggle source
# File lib/factory_girl/callback.rb, line 28 def check_name unless VALID_NAMES.include?(name) raise InvalidCallbackNameError, "#{name} is not a valid callback name. " + "Valid callback names are #{VALID_NAMES.inspect}" end end