lib/pmp/client.rb in pmp-0.5.0 vs lib/pmp/client.rb in pmp-0.5.1

- old
+ new

@@ -20,11 +20,15 @@ @token ||= PMP::Token.new(options.merge(opts)).get_token end def root(opts={}) @root = nil if (opts != {}) - opts = options.merge(href: endpoint).merge(opts) - @root ||= PMP::CollectionDocument.new(opts) + @root ||= new_root(opts) + end + + def new_root(opts={}) + root_options = options.merge(opts).merge(href: endpoint) + PMP::CollectionDocument.new(root_options).tap{|r| r.root = r } end def doc_of_type(type, opts={}) doc = PMP::CollectionDocument.new(options.merge(root:root(opts)).merge(opts)) doc.links['profile'] = Link.new(href: profile_href_for_type(type), type: "application/vnd.collection.doc+json")