class FactoryGirl::RemoteApi::Request
Public Instance Methods
get_response_for(factory_method, factory, attributes)
click to toggle source
# File lib/factory_girl/remote_api/request.rb, line 8 def get_response_for(factory_method, factory, attributes) uri = uri_for(factory_method, factory) uri.query = attributes_as_query(factory, attributes) parsed_response(Net::HTTP.get_response(uri).body, attributes[:parent_factory] || factory.to_s) end
Private Instance Methods
attributes_as_query(factory, attributes)
click to toggle source
# File lib/factory_girl/remote_api/request.rb, line 27 def attributes_as_query(factory, attributes) attributes = { factory.to_sym => attributes } if attributes != {} attributes.to_query end
configuration()
click to toggle source
# File lib/factory_girl/remote_api/request.rb, line 23 def configuration FactoryGirl::RemoteApi.configuration end
parsed_response(response_body, json_root)
click to toggle source
# File lib/factory_girl/remote_api/request.rb, line 32 def parsed_response(response_body, json_root) response_json = JSON.parse(response_body) attributes = response_json.key?(json_root) ? response_json[json_root] : response_json attributes.with_indifferent_access end
uri_for(factory_method, factory)
click to toggle source
# File lib/factory_girl/remote_api/request.rb, line 16 def uri_for(factory_method, factory) factories_path = "#{configuration.server_url}#{configuration.server_mount_path}" factories_path << "/#{factory_method}" if factory_method != :create factories_path << "/#{factory}" URI(factories_path) end