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/null_factory.rb
Joshua Clayton 0c165ec993 Add DefinitionHierarchy to handle inheritance of some definition attributes
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.
2012-07-11 23:05:16 -04:00

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