Module: Roar::Representer::JSON::HAL::Links::LinkCollectionRepresenter

Includes:
Representable::JSON::Hash
Defined in:
lib/roar/representer/json/hal.rb

Instance Method Summary collapse

Instance Method Details

#from_hash(hash, options = {}) ⇒ Object



146
147
148
149
150
151
152
# File 'lib/roar/representer/json/hal.rb', line 146

def from_hash(hash, options={})
  hash.each { |k,v| hash[k] = LinkArray.new(v, k) if is_array?(k) }

  hsh = super(hash) # this is where :class and :extend do the work.

  hsh.each { |k, v| v.rel = k }
end

#to_hash(options) ⇒ Object



139
140
141
142
143
# File 'lib/roar/representer/json/hal.rb', line 139

def to_hash(options)
  super.tap do |hsh|  # TODO: cool: super(:exclude => [:rel]).
    hsh.each { |k,v| v.delete(:rel) }
  end
end