class FactoryGirl::RemoteApi::RemoteFactory

Public Class Methods

model_from(factory_method, factory, attributes) click to toggle source
# File lib/factory_girl/remote_api/remote_factory.rb, line 7
def self.model_from(factory_method, factory, attributes)
  final_attributes = FactoryGirl::RemoteApi::Request.new.get_response_for(factory_method, factory, attributes)
  new.instantiate_model(final_attributes, factory, attributes)
end

Public Instance Methods

instantiate_model(final_attributes, factory, attributes) click to toggle source
# File lib/factory_girl/remote_api/remote_factory.rb, line 12
def instantiate_model(final_attributes, factory, attributes)
  model_instance = model_class(factory, attributes).new
  apply_attributes_to_instance(final_attributes, model_instance)
  model_instance
end

Private Instance Methods

apply_attributes_to_instance(attributes, model_instance) click to toggle source
# File lib/factory_girl/remote_api/remote_factory.rb, line 25
def apply_attributes_to_instance(attributes, model_instance)
  attributes.each { |attr_name, attr_value| model_instance.public_send("#{attr_name}=", attr_value) }
end
model_class(factory, attributes) click to toggle source
# File lib/factory_girl/remote_api/remote_factory.rb, line 20
def model_class(factory, attributes)
  class_name = attributes[:parent_factory] || factory.to_s
  class_name.camelize.constantize
end