Sha256: 748f7d93b38724e4ec1304208dee551e9f6b442c0a34a39c7953e21603d6a286
Contents?: true
Size: 796 Bytes
Versions: 7
Compression:
Stored size: 796 Bytes
Contents
module Materialist module Materializer module Internals class LinkMapping def initialize(key:, mapping: [], enable_caching: false) @key = key @mapping = mapping @enable_caching = enable_caching end attr_reader :mapping def map(resource) return unless linked_resource = linked_resource(resource) mapping.map{ |m| m.map(linked_resource) }.compact.reduce(&:merge) end def linked_resource(resource) return unless href = resource.dig(:_links, @key, :href) resource.client.get(href, options: { enable_caching: @enable_caching, response_class: HateoasResource }) rescue Routemaster::Errors::ResourceNotFound nil end end end end end
Version data entries
7 entries across 7 versions & 1 rubygems