Class: RemoteFactoryGirl::Http
- Inherits:
-
Object
- Object
- RemoteFactoryGirl::Http
- Defined in:
- lib/remote_factory_girl/http.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#http_lib ⇒ Object
readonly
Returns the value of attribute http_lib.
-
#params ⇒ Object
readonly
Returns the value of attribute params.
-
#response_json ⇒ Object
readonly
Returns the value of attribute response_json.
Class Method Summary collapse
- .get(config, params, http_lib = RestClient) ⇒ Object
- .post(config, params, http_lib = RestClient) ⇒ Object
Instance Method Summary collapse
- #get ⇒ Object
-
#initialize(config, params, http_lib = RestClient) ⇒ Http
constructor
A new instance of Http.
- #post ⇒ Object
- #to_hash ⇒ Object
Constructor Details
#initialize(config, params, http_lib = RestClient) ⇒ Http
Returns a new instance of Http.
15 16 17 18 19 20 |
# File 'lib/remote_factory_girl/http.rb', line 15 def initialize(config, params, http_lib = RestClient) config.raise_if_host_not_set @config = config @params = params @http_lib = http_lib end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
13 14 15 |
# File 'lib/remote_factory_girl/http.rb', line 13 def config @config end |
#http_lib ⇒ Object (readonly)
Returns the value of attribute http_lib.
13 14 15 |
# File 'lib/remote_factory_girl/http.rb', line 13 def http_lib @http_lib end |
#params ⇒ Object (readonly)
Returns the value of attribute params.
13 14 15 |
# File 'lib/remote_factory_girl/http.rb', line 13 def params @params end |
#response_json ⇒ Object (readonly)
Returns the value of attribute response_json.
13 14 15 |
# File 'lib/remote_factory_girl/http.rb', line 13 def response_json @response_json end |
Class Method Details
.get(config, params, http_lib = RestClient) ⇒ Object
9 10 11 |
# File 'lib/remote_factory_girl/http.rb', line 9 def self.get(config, params, http_lib = RestClient) new(config, params, http_lib).get end |
.post(config, params, http_lib = RestClient) ⇒ Object
5 6 7 |
# File 'lib/remote_factory_girl/http.rb', line 5 def self.post(config, params, http_lib = RestClient) new(config, params, http_lib).post end |
Instance Method Details
#get ⇒ Object
22 23 24 25 |
# File 'lib/remote_factory_girl/http.rb', line 22 def get @response_json = http_lib.get config.home_url, params.merge!(content_type: :json, accept: :json) self end |
#post ⇒ Object
27 28 29 30 |
# File 'lib/remote_factory_girl/http.rb', line 27 def post @response_json = http_lib.post config.home_url, params, content_type: :json, accept: :json self end |
#to_hash ⇒ Object
32 33 34 |
# File 'lib/remote_factory_girl/http.rb', line 32 def to_hash JSON.parse(response_json) end |