Class: Ezid::Request Private
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- Ezid::Request
- Defined in:
- lib/ezid/request.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
A request to the EZID service.
Constant Summary collapse
- HOST =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
"https://ezid.cdlib.org"- CHARSET =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
"UTF-8"- CONTENT_TYPE =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
"text/plain"
Class Method Summary collapse
Instance Method Summary collapse
-
#execute ⇒ Ezid::Response
private
Executes the request and returns the response.
-
#initialize(method, path) ⇒ Request
constructor
private
A new instance of Request.
Constructor Details
#initialize(method, path) ⇒ Request
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Request.
25 26 27 28 29 30 |
# File 'lib/ezid/request.rb', line 25 def initialize(method, path) http_method = Net::HTTP.const_get(method) uri = URI.parse([HOST, path].join) super(http_method.new(uri)) set_content_type(CONTENT_TYPE, charset: CHARSET) end |
Class Method Details
.execute(*args) {|request| ... } ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
17 18 19 20 21 |
# File 'lib/ezid/request.rb', line 17 def self.execute(*args) request = new(*args) yield request if block_given? request.execute end |
Instance Method Details
#execute ⇒ Ezid::Response
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Executes the request and returns the response
34 35 36 37 38 39 |
# File 'lib/ezid/request.rb', line 34 def execute http_response = Net::HTTP.start(uri.host, use_ssl: true) do |http| http.request(__getobj__) end Response.new(http_response) end |