Sha256: b3839fa1149401cc1bc27729de723da11db0c19f4f002009fcfd8a62eb894382
Contents?: true
Size: 865 Bytes
Versions: 8
Compression:
Stored size: 865 Bytes
Contents
module Hyperclient # Public: A wrapper class to easily acces the embedded resources in a # Resource. # # Examples # # resource.embedded['comments'] # resource.embedded.comments # class ResourceCollection < Collection # Public: Initializes a ResourceCollection. # # collection - The Hash with the embedded resources. # entry_point - The EntryPoint object to inject the configuration. # def initialize(collection, entry_point) @entry_point = entry_point @collection = (collection || {}).reduce({}) do |hash, (name, resource)| hash.update(name => build_resource(resource)) end end private def build_resource(representation) return representation.map(&method(:build_resource)) if representation.is_a?(Array) Resource.new(representation, @entry_point) end end end
Version data entries
8 entries across 8 versions & 1 rubygems