Class | Atom::Collection |
In: |
lib/atom/collection.rb
|
Parent: | Atom::Element |
feed | [R] | |
http | [R] |
# File lib/atom/collection.rb, line 70 def initialize(href = nil, http = Atom::HTTP.new) super() @http = http if href self.href = href end end
# File lib/atom/collection.rb, line 80 def self.parse xml, base = '' e = super # URL absolutization if !e.base.empty? and e.href e.href = (e.base.to_uri + e.href).to_s end e end
# File lib/atom/collection.rb, line 54 def accepts if @accepts.empty? ['application/atom+xml;type=entry'] else @accepts end end
DELETE an entry from the collection
# File lib/atom/collection.rb, line 106 def delete!(entry, url = entry.edit_url) @http.delete(url) end
POST an entry to the collection, with an optional slug
# File lib/atom/collection.rb, line 92 def post!(entry, slug = nil) raise "Cowardly refusing to POST a non-Atom::Entry" unless entry.is_a? Atom::Entry headers = {"Content-Type" => "application/atom+xml" } headers["Slug"] = slug if slug @http.post(@href, entry.to_s, headers) end
POST a media item to the collection
# File lib/atom/collection.rb, line 111 def post_media!(data, content_type, slug = nil) headers = {"Content-Type" => content_type} headers["Slug"] = slug if slug @http.post(@href, data, headers) end
PUT an updated version of an entry to the collection
# File lib/atom/collection.rb, line 101 def put!(entry, url = entry.edit_url) @http.put_atom_entry(entry, url) end