class Roar::JSON::HAL::Links::Representer
Represents all links for “_links”: [Hyperlink, [Hyperlink, Hyperlink]]
Public Instance Methods
from_hash(hash, *args)
click to toggle source
Calls superclass method
# File lib/roar/json/hal.rb, line 147 def from_hash(hash, *args) collection = hash.collect do |rel, value| # "self" => [{"href": "//"}, ] or "self" => {"href": "//"} value.is_a?(Array) ? value.collect { |link| link.merge("rel"=>rel) } : value.merge("rel"=>rel) end super(collection) # [{rel=>self, href=>//}, ..] or {rel=>self, href=>//} end
to_hash(options)
click to toggle source
Calls superclass method
# File lib/roar/json/hal.rb, line 143 def to_hash(options) super.inject({}) { |links, hash| links.merge!(hash) } # [{ rel=>{}, rel=>[{}, {}] }] end