Sha256: a2132e2665ac81850a814dc81a1d49990439c42ae91d63a5fcf2ff94f3d8772c
Contents?: true
Size: 968 Bytes
Versions: 2
Compression:
Stored size: 968 Bytes
Contents
module Yaks class Serializer extend Forwardable include Util attr_reader :resource, :options def_delegators :resource, :links, :attributes, :subresources protected :resource, :links, :attributes, :subresources, :options def initialize(resource, options = {}) @resource = resource @options = YAKS_DEFAULT_OPTIONS.merge(options) end def call serialize_resource(resource) end alias serialize call class << self def register(klass, name, mime_type) @serializers ||= {} @serializers[name] = klass @mime_types ||= {} @mime_types[mime_type] = [name, klass] end def by_name(name) @serializers.fetch(name) end def by_mime_type(mime_type) @mime_types.fetch(mime_type)[1] end def mime_types @mime_types.inject({}) {|memo, (mime_type, (name, _))| memo[name] = mime_type ; memo } end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
yaks-0.4.1 | lib/yaks/serializer.rb |
yaks-0.4.0 | lib/yaks/serializer.rb |