Sha256: 756033b25f03397f5cf27cb55615f81ee77021ae22eb11b42c9e0c933e2c707d
Contents?: true
Size: 747 Bytes
Versions: 3
Compression:
Stored size: 747 Bytes
Contents
module FactoryGirl class Callback VALID_NAMES = [:after_build, :after_create, :after_stub].freeze attr_reader :name, :block def initialize(name, block) @name = name.to_sym @block = block check_name end 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 def ==(other) name == other.name && block == other.block end private 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 end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
factory_girl-2.3.2 | lib/factory_girl/callback.rb |
factory_girl-2.3.1 | lib/factory_girl/callback.rb |
factory_girl-2.3.0 | lib/factory_girl/callback.rb |