Sha256: 69f8d05777ff16f4a195f346ae0fdeed65ac143bd3fb9b38b84254df756ccb37

Contents?: true

Size: 556 Bytes

Versions: 2

Compression:

Stored size: 556 Bytes

Contents

module SirenClient
  class Link
    attr_reader :payload, :rels, :href, :title, :type, :config
    
    def initialize(data, config={})
      if data.class != Hash
        raise ArgumentError, "You must pass in a Hash to SirenClient::Link.new"
      end
      @payload = data
      @config = { format: :json }.merge config 

      @rels  = @payload['rel']   || []
      @href  = @payload['href']  || ''
      @title = @payload['title'] || ''
      @type  = @payload['type']  || ''
    end

    def go
      Entity.new(self.href, @config)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
siren_client-0.1.1 lib/siren_client/link.rb
siren_client-0.1 lib/siren_client/link.rb