lib/roar/representer/xml.rb in roar-0.9.2 vs lib/roar/representer/xml.rb in roar-0.10.0

- old
+ new

@@ -1,6 +1,7 @@ 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. @@ -35,30 +36,26 @@ module ClassMethods include Representable::XML::ClassMethods def links_definition_options - {:from => :link, :class => Hyperlink, :collection => true} + [:links, {:from => :link, :class => Feature::Hypermedia::Hyperlink, :collection => true, :extend => XML::HyperlinkRepresenter}] end # Generic entry-point for parsing. def deserialize(*args) from_xml(*args) end end - - # Encapsulates a hypermedia <link ...>. - class Hyperlink - # TODO: make XML a module to include in Hyperlink < Base. - attr_accessor :rel, :href + module HyperlinkRepresenter include XML self.representation_wrap = :link - property :rel, :from => "rel", :attribute => true - property :href, :from => "href", :attribute => true + Feature::Hypermedia::Hyperlink.params.each do |attr| + property attr, :attribute => true + end end - end end end