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



196
197
198
199
200
201
202
203
204
205
206
207
208
209
# File 'lib/roar/json/hal.rb', line 196

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