Module: Rufus::Google::CollectionMixin

Included in:
Calendar
Defined in:
lib/rufus/google.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#hrefObject (readonly)

Returns the value of attribute href.



118
119
120
# File 'lib/rufus/google.rb', line 118

def href
  @href
end

#nameObject (readonly)

Returns the value of attribute name.



118
119
120
# File 'lib/rufus/google.rb', line 118

def name
  @name
end

Instance Method Details

#delete!(entry) ⇒ Object

Removes an object from the collection



145
146
147
148
149
150
151
152
153
154
155
156
# File 'lib/rufus/google.rb', line 145

def delete! (entry)

  uri = entry.entry.edit_url

  #r = collection.delete!(nil, uri)
  r = collection.http.delete(uri, nil, { 'If-Match' => entry.etag })

  raise "failed to delete entry (#{r.code}): #{r.body}" \
    unless r.code.to_i == 200

  r
end

#initialize(auth_token, entry) ⇒ Object



120
121
122
123
124
125
# File 'lib/rufus/google.rb', line 120

def initialize (auth_token, entry)

  @token = auth_token
  @name = entry.title.to_s
  @href = entry.links.find { |l| l.rel == 'alternate' }.href
end

#post!(o) ⇒ Object

Posts (creates) an object

Returns the URI of the created resource.



132
133
134
135
136
137
138
139
140
# File 'lib/rufus/google.rb', line 132

def post! (o)

  r = collection.post!(o.entry)

  raise "posting object of class #{o.class} failed : #{r.body}" \
    unless r.code.to_i == 201

  r['Location']
end