Module Rufus::Google::CollectionMixin
In: lib/rufus/google.rb

Methods

collection   delete!   new   post!  

Attributes

href  [R] 
name  [R] 

Public Class methods

[Source]

     # File lib/rufus/google.rb, line 120
120:     def initialize (auth_token, entry)
121: 
122:       @token = auth_token
123:       @name = entry.title.to_s
124:       @href = entry.links.find { |l| l.rel == 'alternate' }.href
125:     end

Public Instance methods

Removes an object from the collection

[Source]

     # File lib/rufus/google.rb, line 145
145:     def delete! (entry)
146: 
147:       uri = entry.entry.edit_url
148: 
149:       #r = collection.delete!(nil, uri)
150:       r = collection.http.delete(uri, nil, { 'If-Match' => entry.etag })
151: 
152:       raise "failed to delete entry (#{r.code}): #{r.body}" \
153:         unless r.code.to_i == 200
154: 
155:       r
156:     end

Posts (creates) an object

Returns the URI of the created resource.

[Source]

     # File lib/rufus/google.rb, line 132
132:     def post! (o)
133: 
134:       r = collection.post!(o.entry)
135: 
136:       raise "posting object of class #{o.class} failed : #{r.body}" \
137:         unless r.code.to_i == 201
138: 
139:       r['Location']
140:     end

Protected Instance methods

returns the Atom::Collection instance

[Source]

     # File lib/rufus/google.rb, line 163
163:       def collection
164: 
165:         return @collection if @collection
166: 
167:         @collection = Atom::Collection.new(
168:           href, Rufus::Google::Http.new(@token))
169:       end

[Validate]