Sha256: de1c41c50fda9e4178f70ed38097adc531e5f821bf3118bcb3230a46ccd6857d

Contents?: true

Size: 840 Bytes

Versions: 6

Compression:

Stored size: 840 Bytes

Contents

module {{namespace_module}}
  module {{resource_module}}
    module List
      class Denormalizer
        include Shogun::Denormalizer
        include {{resource_module}}

        MAPPING = {
          "id" => "id",
          "created_at" => "created_at",
          "destroyed_at" => "destroyed_at",
          "updated_at" => "updated_at",
          "href" => "href",
          LINKS_KEY => "links",
          META_KEY => "meta",
          LINKED_KEY => "linked"
        }

        private def document
          @object.map do |object|
            if @fields.one?
              object.public_send(@fields.first)
            else
              @fields.inject({}) do |hash, field|
                hash.merge(field => object.public_send(mapping[field]))
              end
            end
          end
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
shogun-6.4.2 scaffold/generate/resource/list/denormalizer.rb
shogun-6.4.1 scaffold/generate/resource/list/denormalizer.rb
shogun-6.4.0 scaffold/generate/resource/list/denormalizer.rb
shogun-6.3.0 scaffold/generate/resource/list/denormalizer.rb
shogun-6.2.3 scaffold/generate/resource/list/denormalizer.rb
shogun-6.2.2 scaffold/generate/resource/list/denormalizer.rb