Class: Ape::Collection
- Inherits:
-
Object
- Object
- Ape::Collection
- Defined in:
- lib/ape/collection.rb
Instance Method Summary collapse
- #crumbs ⇒ Object
-
#initialize(uri, authent = nil) ⇒ Collection
constructor
The argument has to be an absolute URI.
-
#post(opts = {}) ⇒ Object
Post a new element to this collection; return either an Ape::Entry or an error-message.
Constructor Details
#initialize(uri, authent = nil) ⇒ Collection
The argument has to be an absolute URI
13 14 15 16 |
# File 'lib/ape/collection.rb', line 13 def initialize(uri, authent = nil) @uri = uri @authent = authent end |
Instance Method Details
#crumbs ⇒ Object
40 41 42 |
# File 'lib/ape/collection.rb', line 40 def crumbs return @invoker.crumbs end |
#post(opts = {}) ⇒ Object
Post a new element to this collection; return either an Ape::Entry or
an error-
Options
* :data - element to post as a string
* :type - content type. By default 'application/atom+xml;type=entry'
* :slug - slug header
26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/ape/collection.rb', line 26 def post(opts = {}) return ':data argument not provided' unless opts[:data] type = opts[:type] || Names::AtomEntryMediaType @invoker = Poster.new(@uri, @authent) @invoker['Slug'] = opts[:slug] if opts[:slug] if @invoker.post(type, opts[:data]) @invoker.entry else @invoker.last_error end end |