Sha256: 4f31831333a88a007405f7f7df366271735fed826056ae8a99affde7c70d6c45

Contents?: true

Size: 813 Bytes

Versions: 2

Compression:

Stored size: 813 Bytes

Contents

module ActiveModel
  class Serializer
    class Adapter
      class JsonApi < Adapter
        class FragmentCache

          def fragment_cache(root, cached_hash, non_cached_hash)
            hash              = {}
            core_cached       = cached_hash.first
            core_non_cached   = non_cached_hash.first
            no_root_cache     = cached_hash.delete_if {|key, value| key == core_cached[0] }
            no_root_non_cache = non_cached_hash.delete_if {|key, value| key == core_non_cached[0] }
            cached_resource   = (core_cached[1]) ? core_cached[1].merge(core_non_cached[1]) : core_non_cached[1]
            hash = (root) ? { root => cached_resource } : cached_resource
            hash.merge no_root_non_cache.merge no_root_cache
          end

        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
cm-active_model_serializers-0.10.0.rc1.1 lib/active_model/serializer/adapter/json_api/fragment_cache.rb
active_model_serializers-0.10.0.rc1 lib/active_model/serializer/adapter/json_api/fragment_cache.rb