Sha256: 84cb965c3ec1c6247d61af2e7391746edcc55cb354395d2a1758935952831f22
Contents?: true
Size: 831 Bytes
Versions: 11
Compression:
Stored size: 831 Bytes
Contents
module Shogun class Presenters include Enumerable def initialize(resources:, cast:, includes: [], meta: {}, links: {}, linked: {}) @cast = @cast @sources = resources.map do |resource| cast.new(resource: resource, includes: includes) end @includes = includes @meta = meta @links = links @linked = linked end def each(&block) @sources.each(&block) end def meta @meta end def linked @linked end def links @links.tap do |hash| includes.each do |name| hash.store("#{namespace}.#{name}", [host, name, "{#{namespace}.#{name}}"].join("/")) end end end private def namespace @cast.const_get("NAMESPACE") end private def includes @includes end end end
Version data entries
11 entries across 11 versions & 1 rubygems