Class: Perry::Adapters::RestfulHTTPAdapter
- Inherits:
-
AbstractAdapter
- Object
- AbstractAdapter
- Perry::Adapters::RestfulHTTPAdapter
- Defined in:
- lib/perry/adapters/restful_http_adapter.rb
Defined Under Namespace
Classes: KeyError
Instance Attribute Summary collapse
-
#last_response ⇒ Object
readonly
Returns the value of attribute last_response.
Attributes inherited from AbstractAdapter
Instance Method Summary collapse
Methods inherited from AbstractAdapter
#call, create, #execute, #extend_adapter, #initialize, #middlewares, #processors, register_as
Methods included from Logger
Constructor Details
This class inherits a constructor from Perry::Adapters::AbstractAdapter
Instance Attribute Details
#last_response ⇒ Object (readonly)
Returns the value of attribute last_response.
16 17 18 |
# File 'lib/perry/adapters/restful_http_adapter.rb', line 16 def last_response @last_response end |
Instance Method Details
#delete(options) ⇒ Object
32 33 34 |
# File 'lib/perry/adapters/restful_http_adapter.rb', line 32 def delete() delete_http([:object]) end |
#read(options) ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/perry/adapters/restful_http_adapter.rb', line 18 def read() response = get_http([:relation]) unless response.parsed.is_a?(Array) raise Perry::MalformedResponse, "Expected instance of Array got '#{response.raw.inspect}'" end response.array_attributes end |
#write(options) ⇒ Object
26 27 28 29 30 |
# File 'lib/perry/adapters/restful_http_adapter.rb', line 26 def write() object = [:object] params = build_params_from_attributes(object) object.new_record? ? post_http(object, params) : put_http(object, params) end |