Class: ActiveResource::Base
- Inherits:
-
Object
- Object
- ActiveResource::Base
- Defined in:
- lib/sk_sdk/ar_patches/ar3/base.rb,
lib/sk_sdk/ar_patches/ar4/base.rb
Overview
Overridden methods to suit SalesKing’s nested json format only valid for AR 4+ In the future might add a custom format class, see base.format
Direct Known Subclasses
Instance Method Summary collapse
-
#load_attributes_from_response(response) ⇒ Object
override ARes method to parse only the client part.
Instance Method Details
#load_attributes_from_response(response) ⇒ Object
override ARes method to parse only the client part
8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/sk_sdk/ar_patches/ar3/base.rb', line 8 def load_attributes_from_response(response) if (response['Transfer-Encoding'] == 'chunked' || (!response['Content-Length'].blank? && response['Content-Length'] != "0")) && !response.body.nil? && response.body.strip.size > 0 load( self.class.format.decode(response.body)[self.class.element_name] ) #fix double nested items .. active resource SUCKS soooo bad if self.respond_to?(:items) new_items = [] self.items.each { |item| new_items << item.attributes.first[1] } self.items = new_items end @persisted = true end end |