Sha256: 1d1f11ffd08b73ff79e87ff3d4b1e141dda64fb14bd5bb061a23f2432b6773e6

Contents?: true

Size: 863 Bytes

Versions: 7

Compression:

Stored size: 863 Bytes

Contents

module ActiveResource
  # Overridden methods to suit SalesKing.
  # Some changes might be kicked when AR 3.0 is out
  class Base

    # override ARes method to parse only the client part
    def load_attributes_from_response(response)
      if response['Content-Length'] != "0" && response.body.strip.size > 0
        load( self.class.format.decode(response.body)[self.class.element_name] )
      end
    end

    # Overridden to grab the data(= clients-collection) from json:
    # { 'collection'=> will_paginate infos,
    #   'links' => prev/next links
    #   'clients'=> [data], << what we need
    # }
    def self.instantiate_collection(collection, prefix_options = {})
      collection = collection[ self.element_name.pluralize ] if collection.is_a?(Hash)
      collection.collect! { |record| instantiate_record(record, prefix_options) }
    end
  end
end

Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
sk_sdk-0.0.8 lib/sk_sdk/ar_patches/ar3/base.rb
sk_sdk-0.0.7 lib/sk_sdk/ar_cli/patches/ar3/base.rb
sk_sdk-0.0.6 lib/sk_sdk/ar_cli/patches/ar3/base.rb
sk_sdk-0.0.5 lib/sk_sdk/ar_cli/patches/ar3/base.rb
sk_sdk-0.0.4 lib/sk_sdk/ar_cli/patches/ar3/base.rb
sk_sdk-0.0.3 lib/sk_sdk/ar_cli/patches/ar3/base.rb
sk-api-1.1.0 lib/patches/ar3/base.rb