lib/restfulie/client/http/atom_ext.rb in restfulie-0.7.0 vs lib/restfulie/client/http/atom_ext.rb in restfulie-0.7.1

- old
+ new

@@ -1,24 +1,6 @@ module Restfulie::Client::HTTP#:nodoc: - - # Offer easy access to Atom link relationships, such as <tt>post.next</tt> for - # <tt>&lt;link rel="next" href="http://resource.entrypoint.com/post/12" type="application/atom+xml" /&gt;</tt> relationships. - module AtomLinkShortcut - def method_missing(method_sym,*args)#:nodoc: - selected_links = links.select{ |l| l.rel == method_sym.to_s } - super if selected_links.empty? - link = (selected_links.size == 1) ? selected_links.first : selected_links - - return link unless link.instance_variable_defined?(:@type) - link.accepts(link.type) - - representation = Restfulie::Client::HTTP::RequestMarshaller.content_type_for(link.type) - return representation.prepare_link_for(link) if representation - link - - end - end # Offers a way to access Atom entries element's in namespaced extensions. module AtomElementShortcut def method_missing(method_sym,*args) return super(method_sym, *args) unless simple_extensions @@ -62,26 +44,26 @@ end result.length==1 ? result.first : result end end - # Gives to Atom::Link capabilities to fetch related resources. - module LinkRequestBuilder - include RequestMarshaller - def path#:nodoc: - at(href) - super - end - end - # inject new behavior in rAtom instances to enable easily access to link relationships. ::Atom::Feed.instance_eval { - include AtomLinkShortcut + include Restfulie::Client::LinkShortcut include AtomElementShortcut } ::Atom::Entry.instance_eval { - include AtomLinkShortcut + include Restfulie::Client::LinkShortcut include AtomElementShortcut } - ::Atom::Link.instance_eval { include LinkRequestBuilder } + ::Atom::Link.instance_eval { + include Restfulie::Client::HTTP::LinkRequestBuilder + } +end + + +class Atom::Link + def content_type + type + end end