Class Atom::Collection
In: lib/atom/collection.rb
Parent: Atom::Element

Methods

accepts   accepts=   delete!   new   parse   post!   post_media!   put!   put_media!   title  

Attributes

feed  [R] 
http  [R] 

Public Class methods

[Source]

# 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

[Source]

# 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

Public Instance methods

[Source]

# File lib/atom/collection.rb, line 54
    def accepts
      if @accepts.empty?
        ['application/atom+xml;type=entry']
      else
        @accepts
      end
    end

[Source]

# File lib/atom/collection.rb, line 62
    def accepts= array
      @accepts = array
    end

DELETE an entry from the collection

[Source]

# 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

[Source]

# 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

[Source]

# 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

[Source]

# File lib/atom/collection.rb, line 101
    def put!(entry, url = entry.edit_url)
      @http.put_atom_entry(entry, url)
    end

PUT a media item to the collection

[Source]

# File lib/atom/collection.rb, line 119
    def put_media!(data, content_type, slug = nil)
      headers = {"Content-Type" => content_type}

      @http.put(url, data, headers)
    end

[Source]

# File lib/atom/collection.rb, line 50
    def title
      @title or @feed.title
    end

[Validate]