Sha256: 57ed561248e765f3f40971629c55a2e6ad114a437050ee24110ecf566ab3ea15

Contents?: true

Size: 645 Bytes

Versions: 2

Compression:

Stored size: 645 Bytes

Contents

require 'hyperclient/collection'
require 'hyperclient/link'

module Hyperclient
  # Public: A wrapper class to easily acces the links in a  Resource.
  #
  # Examples
  #
  #   resource.links['author']
  #   resource.links.author
  #
  class LinkCollection < Collection
    # Public: Initializes a LinkCollection.
    #
    # collection  - The Hash with the links.
    # entry_point - The EntryPoint object to inject the cofnigutation.
    #
    def initialize(collection, entry_point)
      @collection = (collection || {}).inject({}) do |hash, (name, link)|
        hash.update(name => Link.new(link, entry_point))
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
hyperclient-0.2.0 lib/hyperclient/link_collection.rb
hyperclient-0.1.0 lib/hyperclient/link_collection.rb