-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Runcible was built around being able to take a rest client response body, pull out relevant details and craft a new rest client response object with the boy being the parsed json rather than the raw json. Rest Client 2.0 makes this impossible by making the Response object extend string. To resolve this while attempting to not break compatibility, we have introduced a Runcible::Response object that attempts to pass method calls to the parsed JSON body, and if that does not make sense, to the Rest Client Response object. Even still, I still bumped the version to 2.0 in case there is any change I am not seeing.
- Loading branch information
1 parent
ee18d55
commit e5f2394
Showing
6 changed files
with
43 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
module Runcible | ||
class Response | ||
attr_accessor :rest_client_response, :parsed_body | ||
|
||
def initialize(parsed_body, rest_client_response) | ||
@rest_client_response = rest_client_response | ||
@parsed_body = parsed_body | ||
end | ||
|
||
def respond_to?(name) | ||
@parsed_body.respond_to?(name) || @rest_client_response.respond_to?(name) | ||
end | ||
|
||
def ==(other) | ||
self.parsed_body == other | ||
end | ||
|
||
def is_a?(clazz) | ||
self.parsed_body.is_a?(clazz) | ||
end | ||
|
||
def body | ||
@parsed_body | ||
end | ||
|
||
def method_missing(name, *args, &block) | ||
if @parsed_body.respond_to?(name) | ||
@parsed_body.send(name, *args, &block) | ||
elsif @rest_client_response.respond_to?(name) | ||
@rest_client_response.send(name, *args, &block) | ||
else | ||
super | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
module Runcible | ||
VERSION = '1.11.0'.freeze | ||
VERSION = '2.0.0'.freeze | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters