Sha256: 51a4db31e2a44c9f948a261b2789051a7c5a787a6be054f509928b666194f7bb
Contents?: true
Size: 735 Bytes
Versions: 14
Compression:
Stored size: 735 Bytes
Contents
module Almodovar class ResourcePresenter class JsonSerializer < Serializer def to_json require 'yajl' Yajl::Encoder.encode(as_json, :pretty => true) + "\n" end def as_json ActiveSupport::OrderedHash[:resource_type, resource.resource_type].tap do |message| message.merge! attributes_as_json message.merge! links_as_json end end private def attributes_as_json resource.attributes end def links_as_json resource.all_links.inject(ActiveSupport::OrderedHash.new) do |message, link| message.merge! link.as_json(options_for_link) end end end end end
Version data entries
14 entries across 14 versions & 2 rubygems