mirror of
https://github.com/thoughtbot/factory_bot.git
synced 2022-11-09 11:43:51 -05:00
29 lines
577 B
Ruby
29 lines
577 B
Ruby
class Factory
|
|
class Proxy #:nodoc:
|
|
class Build < Proxy #:nodoc:
|
|
def initialize(klass)
|
|
@instance = klass.new
|
|
end
|
|
|
|
def get(attribute)
|
|
@instance.send(attribute)
|
|
end
|
|
|
|
def set(attribute, value)
|
|
@instance.send(:"#{attribute}=", value)
|
|
end
|
|
|
|
def associate(name, factory, attributes)
|
|
set(name, Factory.create(factory, attributes))
|
|
end
|
|
|
|
def association(factory, overrides = {})
|
|
Factory.create(factory, overrides)
|
|
end
|
|
|
|
def result
|
|
@instance
|
|
end
|
|
end
|
|
end
|
|
end
|