mirror of
https://github.com/thoughtbot/factory_bot.git
synced 2022-11-09 11:43:51 -05:00
0c165ec993
This includes #callbacks, #constructor, and #to_create. The reasoning behind this is that we were mimicing an inheritance chain via methods; now, we actually generate classes, which Factory maintains, who inherit from their parent's hierarchy. We build the hierarchy during compilation to conditionally define methods based on whether what we're dealing with from the definition is actually meaningful. The base class (DefinitionHierarchy) uses the defaults (an empty array for #callbacks and the global #to_create and #constructor) so once we hit the top level, if the definition doesn't set any overrides, we have a list of sensible values.
18 lines
438 B
Ruby
18 lines
438 B
Ruby
module FactoryGirl
|
|
# @api private
|
|
class NullFactory
|
|
attr_reader :definition
|
|
|
|
def initialize
|
|
@definition = Definition.new(:null_factory)
|
|
end
|
|
|
|
delegate :defined_traits, :callbacks, :attributes, :constructor,
|
|
:to_create, to: :definition
|
|
|
|
def compile; end
|
|
def class_name; end
|
|
def evaluator_class; FactoryGirl::Evaluator; end
|
|
def hierarchy_class; FactoryGirl::DefinitionHierarchy; end
|
|
end
|
|
end
|