Sha256: 922a47dec0de0511452db411a2f75c2200d70765f08ee54ef881c3506d0f4752
Contents?: true
Size: 1.31 KB
Versions: 4
Compression:
Stored size: 1.31 KB
Contents
module Almodovar class ResourcePresenter autoload :Serializer, 'almodovar-server/resource_presenter/serializer' autoload :XmlSerializer, 'almodovar-server/resource_presenter/xml_serializer' autoload :JsonSerializer, 'almodovar-server/resource_presenter/json_serializer' autoload :HtmlSerializer, 'almodovar-server/resource_presenter/html_serializer' autoload :Metadata, 'almodovar-server/resource_presenter/metadata' extend Metadata attr_accessor :url def attributes @attributes ||= ActiveSupport::OrderedHash.new end def links @links ||= [] end def self.resource_type name.gsub(/Resource$/, '').underscore end def resource_class self.class end def resource_type resource_class.resource_type end def to_xml(options = {}) XmlSerializer.new(self, options).to_xml end def to_json(options = {}) JsonSerializer.new(self, options).to_json end def as_json(options = {}) JsonSerializer.new(self, options).as_json end def to_html(options = {}) HtmlSerializer.new(self, options).to_html end def all_links ([link_to_self] + links).compact end def link_to_self Link.new(:self, @url) if @url end end end
Version data entries
4 entries across 4 versions & 1 rubygems