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/declaration/implicit.rb

32 lines
733 B
Ruby
Raw Normal View History

module FactoryGirl
class Declaration
class Implicit < Declaration
def initialize(name, factory = nil, ignored = false)
super(name, ignored)
@factory = factory
end
def ==(other)
name == other.name &&
factory == other.factory &&
ignored == other.ignored
end
protected
attr_reader :factory
private
def build
if FactoryGirl.factories.registered?(name)
[Attribute::Association.new(name, name, {})]
elsif FactoryGirl.sequences.registered?(name)
[Attribute::Sequence.new(name, name, @ignored)]
else
@factory.trait_by_name(name).attributes.to_a
end
end
end
end
end