Class: Oos4ruby::Bean::BeanClass

Inherits:
Object
  • Object
show all
Defined in:
lib/oos4ruby/bean.rb

Direct Known Subclasses

Contact, Media, Site, User

Instance Method Summary collapse

Instance Method Details

#authorObject



92
93
94
# File 'lib/oos4ruby/bean.rb', line 92

def author
  @entry.child('author/name').text
end

#contains?(elem, value) ⇒ Boolean

Returns:

  • (Boolean)


104
105
106
107
# File 'lib/oos4ruby/bean.rb', line 104

def contains?(elem, value)
  xpath = @xml.first(elem)
  return xpath && xpath.text == value
end

#delete!Object

Raises:

  • (RuntimeError)


128
129
130
131
132
133
134
135
136
# File 'lib/oos4ruby/bean.rb', line 128

def delete!
  edit_link = @xml.link('edit')

  deleter = HTTPInvoker.new(edit_link, @auth)

  worked = deleter.delete

  raise RuntimeError.new unless worked    
end

#to_sObject



100
101
102
# File 'lib/oos4ruby/bean.rb', line 100

def to_s
  @xml.to_s
end

#to_xmlObject



96
97
98
# File 'lib/oos4ruby/bean.rb', line 96

def to_xml
  @xml.to_s
end

#update!Object



109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
# File 'lib/oos4ruby/bean.rb', line 109

def update!
  edit_link = @xml.link('edit')

  getter = HTTPInvoker.new(edit_link, @auth)

  worked = getter.get
  if worked
    @xml = Entry.new( getter.body )
    load!

    putter = HTTPInvoker.new edit_link, @auth
    worked = putter.put AtomEntryContentType, @xml.to_s

    raise RuntimeError.new unless worked
  else
    raise RuntimeError.new unless worked
  end    
end