Module: Roar::JSON::HAL::LinksReader

Defined in:
lib/roar/json/hal.rb

Overview

This is only helpful in client mode. It shouldn't be used per default.

Instance Method Summary collapse

Instance Method Details


201
202
203
204
205
206
207
208
209
210
211
212
213
214
# File 'lib/roar/json/hal.rb', line 201

def links
  return unless @links
  tuples = @links.collect do |link|
    if link.is_a?(Array)
      next unless link.any?
      [link.first.rel, link]
    else
      [link.rel, link]
    end
  end.compact

  # tuples.to_h
  ::Hash[tuples] # TODO: tuples.to_h when dropping < 2.1.
end