Sha256: 254143fde98916a0a1be0c27e53c8877cc85992b55359c18d184c37dd14200a7
Contents?: true
Size: 1.34 KB
Versions: 4
Compression:
Stored size: 1.34 KB
Contents
require 'roar/representer' require 'roar/hypermedia' require 'representable/xml' module Roar # Includes #from_xml and #to_xml into your represented object. # In addition to that, some more options are available when declaring properties. module XML def self.included(base) base.class_eval do include Representer # Roar::Representer, this is needed for Rails URL helpers include Representable::XML extend ClassMethods include InstanceMethods # otherwise Representable overrides our #to_xml. end end module InstanceMethods # Generic entry-point for rendering. def serialize(*args) to_xml(*args) end def deserialize(*args) from_xml(*args) end end module ClassMethods include Representable::XML::ClassMethods def links_definition_options # FIXME: this doesn't belong into the generic XML representer. { :as => :link, :class => Hypermedia::Hyperlink, :extend => XML::HyperlinkRepresenter, :exec_context => :decorator, collection: true } # TODO: merge with JSON. end end require 'representable/xml/hash' module HyperlinkRepresenter include Representable::XML::AttributeHash self.representation_wrap = :link end end end
Version data entries
4 entries across 4 versions & 2 rubygems
Version | Path |
---|---|
blacklight-spotlight-3.6.0.beta8 | vendor/bundle/ruby/3.2.0/gems/roar-1.2.0/lib/roar/xml.rb |
roar-1.2.0 | lib/roar/xml.rb |
roar-1.1.1 | lib/roar/xml.rb |
roar-1.1.0 | lib/roar/xml.rb |