2012-05-12 10:27:47 -04:00
module FactoryGirl
# @api private
class Configuration
attr_reader :factories , :sequences , :traits , :strategies , :callback_names
2016-02-29 16:35:34 -05:00
attr_accessor :allow_class_lookup
2012-05-12 10:27:47 -04:00
def initialize
2012-06-08 17:25:18 -04:00
@factories = Decorator :: DisallowsDuplicatesRegistry . new ( Registry . new ( 'Factory' ) )
@sequences = Decorator :: DisallowsDuplicatesRegistry . new ( Registry . new ( 'Sequence' ) )
@traits = Decorator :: DisallowsDuplicatesRegistry . new ( Registry . new ( 'Trait' ) )
2012-05-12 10:27:47 -04:00
@strategies = Registry . new ( 'Strategy' )
@callback_names = Set . new
2012-05-12 00:42:44 -04:00
@definition = Definition . new
2016-02-29 16:35:34 -05:00
@allow_class_lookup = true
2013-12-14 22:33:15 -05:00
to_create { | instance | instance . save! }
2012-05-12 18:53:17 -04:00
initialize_with { new }
2012-05-12 10:27:47 -04:00
end
2012-05-12 00:42:44 -04:00
2013-02-08 11:00:22 -05:00
delegate :to_create , :skip_create , :constructor , :before , :after ,
:callback , :callbacks , to : :@definition
2012-05-12 18:53:17 -04:00
def initialize_with ( & block )
@definition . define_constructor ( & block )
end
2012-07-27 14:10:38 -04:00
def duplicate_attribute_assignment_from_initialize_with
false
end
def duplicate_attribute_assignment_from_initialize_with = ( value )
ActiveSupport :: Deprecation . warn 'Assignment of duplicate_attribute_assignment_from_initialize_with is unnecessary as this is now default behavior in FactoryGirl 4.0; this line can be removed' , caller
end
2012-05-12 10:27:47 -04:00
end
end