Class: ClientAuth::Resource
- Inherits:
-
RestClient::Resource
- Object
- RestClient::Resource
- ClientAuth::Resource
- Defined in:
- lib/client_auth/resource.rb
Instance Attribute Summary collapse
-
#signer ⇒ Object
readonly
Returns the value of attribute signer.
Instance Method Summary collapse
- #args_for(name, payload, additional_headers) ⇒ Object
- #client_request(args) ⇒ Object
-
#initialize(url, options = {}, backwards_compatibility = nil, &block) ⇒ Resource
constructor
A new instance of Resource.
- #patch(payload, additional_headers = {}, &block) ⇒ Object
- #post(payload, additional_headers = {}, &block) ⇒ Object
Constructor Details
#initialize(url, options = {}, backwards_compatibility = nil, &block) ⇒ Resource
Returns a new instance of Resource.
5 6 7 8 |
# File 'lib/client_auth/resource.rb', line 5 def initialize(url, = {}, backwards_compatibility = nil, &block) @signer = [:signer] super(url, , backwards_compatibility, &block) end |
Instance Attribute Details
#signer ⇒ Object (readonly)
Returns the value of attribute signer.
3 4 5 |
# File 'lib/client_auth/resource.rb', line 3 def signer @signer end |
Instance Method Details
#args_for(name, payload, additional_headers) ⇒ Object
27 28 29 30 |
# File 'lib/client_auth/resource.rb', line 27 def args_for(name, payload, additional_headers) headers = ([:headers] || {}).merge(additional_headers) .merge(method: name, url: url, payload: payload, headers: headers) end |
#client_request(args) ⇒ Object
20 21 22 23 24 25 |
# File 'lib/client_auth/resource.rb', line 20 def client_request(args) ClientAuth::Request.new(args).tap do |client_request| signer.payload = client_request.payload client_request.init_headers(args, signer) end end |
#patch(payload, additional_headers = {}, &block) ⇒ Object
15 16 17 18 |
# File 'lib/client_auth/resource.rb', line 15 def patch(payload, additional_headers = {}, &block) args = args_for(:patch, payload, additional_headers) client_request(args).execute(&(block || @block)) end |
#post(payload, additional_headers = {}, &block) ⇒ Object
10 11 12 13 |
# File 'lib/client_auth/resource.rb', line 10 def post(payload, additional_headers = {}, &block) args = args_for(:post, payload, additional_headers) client_request(args).execute(&(block || @block)) end |