Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow all HTTParty's options for Neo4j Sessions, #51
- Loading branch information
1 parent
80871d0
commit 7507da0
Showing
6 changed files
with
52 additions
and
32 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 |
---|---|---|
@@ -1,20 +1,24 @@ | ||
module Neo4j::Server | ||
class Neo4jServerEndpoint | ||
def initialize(url, params = nil) | ||
unless params.nil? | ||
@auth = params if params[:basic_auth] | ||
end | ||
def initialize(params = {}) | ||
@params = params | ||
end | ||
|
||
["get", "post", "delete"].each do |verb| | ||
define_method verb do |url, *params| | ||
unless @auth.nil? | ||
params.push({}) if params.empty? | ||
params.last.merge!(@auth) | ||
end | ||
def merged_options(options) | ||
options.merge!(@params) | ||
end | ||
|
||
def get(url, options={}) | ||
HTTParty.get(url, merged_options(options)) | ||
end | ||
|
||
HTTParty.send(verb, url, *params) | ||
end | ||
def post(url, options={}) | ||
HTTParty.post(url, merged_options(options)) | ||
end | ||
|
||
def delete(url, options={}) | ||
HTTParty.delete(url, merged_options(options)) | ||
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
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