Sha256: 6c8ad764a1e36d6dd3db090e94b1705895f63a3d1e0fa08b97b2c7394cf06347

Contents?: true

Size: 759 Bytes

Versions: 5

Compression:

Stored size: 759 Bytes

Contents

module SirenClient
  class Link
    include Modules::WithRawResponse

    attr_accessor :href
    attr_reader :payload, :rels, :title, :type, :config

    def initialize(data, config={})
      super()
      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
      if next_response_is_raw?
        disable_raw_response
        generate_raw_response(:get, self.href, @config)
      else
        Entity.new(self.href, @config)
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
siren_client-2.0.1 lib/siren_client/link.rb
siren_client-2.0.0 lib/siren_client/link.rb
siren_client-1.0.2 lib/siren_client/link.rb
siren_client-1.0.1 lib/siren_client/link.rb
siren_client-1.0.0 lib/siren_client/link.rb