Sha256: e8a3a30b92e1c14f0900925f6d7865144501135889b5bf329f80edbd1e02ff3c
Contents?: true
Size: 1.65 KB
Versions: 2
Compression:
Stored size: 1.65 KB
Contents
require 'roar/representer' require 'roar/representer/feature/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 Representer module XML def self.included(base) base.class_eval do include Representer include Representable::XML extend ClassMethods include InstanceMethods # otherwise Representable overrides our #to_xml. end end module InstanceMethods def to_xml(*args) before_serialize(*args) super end # 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. [:links_array, {:from => :link, :class => Feature::Hypermedia::Hyperlink, :collection => true, :extend => XML::HyperlinkRepresenter, :representer_exec => true, :getter => lambda { |*| links_array }, :setter => lambda { |val,*| self.links_array=(val) } }] # TODO: merge with JSON. end # Generic entry-point for parsing. def deserialize(*args) from_xml(*args) end end require 'representable/xml/hash' module HyperlinkRepresenter include Representable::XML::AttributeHash self.representation_wrap = :link end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
roar-0.11.17 | lib/roar/representer/xml.rb |
roar-0.11.16 | lib/roar/representer/xml.rb |