Sha256: 52dbf629b161f9bf5d46d2b6ab67cbd1e13ee3dd0341e47b4a7561b47cc3edd6

Contents?: true

Size: 526 Bytes

Versions: 3

Compression:

Stored size: 526 Bytes

Contents

module ActiveResource
  class Base
    def encode(options = {})
      same = dup
      same.attributes = {self.class.element_name => same.attributes} if self.class.format.extension == 'json'

      same.send("to_#{self.class.format.extension}", options)
    end
  end

  module Formats
    module JsonFormat
      def decode(json)
        data = ActiveSupport::JSON.decode(json)
        if data.is_a?(Hash) && data.keys.size == 1
          data.values.first
        else
          data
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
shopify_api-2.2.0 lib/shopify_api/json_format.rb
shopify_api-2.1.0 lib/shopify_api/json_format.rb
shopify_api-2.0.0 lib/shopify_api/json_format.rb