2011-09-23 13:14:02 -04:00
|
|
|
module FactoryGirl
|
|
|
|
class Declaration
|
|
|
|
class Implicit < Declaration
|
2011-10-07 18:19:27 -04:00
|
|
|
def initialize(name, factory = nil, ignored = false)
|
|
|
|
super(name, ignored)
|
2011-09-23 13:14:02 -04:00
|
|
|
@factory = factory
|
|
|
|
end
|
|
|
|
|
2011-10-14 15:14:43 -04:00
|
|
|
def ==(other)
|
|
|
|
name == other.name &&
|
|
|
|
factory == other.factory &&
|
|
|
|
ignored == other.ignored
|
|
|
|
end
|
|
|
|
|
|
|
|
protected
|
|
|
|
attr_reader :factory
|
|
|
|
|
2011-09-23 13:14:02 -04:00
|
|
|
private
|
|
|
|
|
|
|
|
def build
|
|
|
|
if FactoryGirl.factories.registered?(name)
|
|
|
|
[Attribute::Association.new(name, name, {})]
|
|
|
|
elsif FactoryGirl.sequences.registered?(name)
|
2011-10-07 18:19:27 -04:00
|
|
|
[Attribute::Sequence.new(name, name, @ignored)]
|
2011-09-23 13:14:02 -04:00
|
|
|
else
|
2011-10-28 17:01:27 -04:00
|
|
|
@factory.trait_by_name(name).attributes.to_a
|
2011-09-23 13:14:02 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|