Module: RubyRest::Atom::EntryBinder

Defined in:
lib/rubyrest/atom.rb

Overview

Very simple module that adds some binding facilities

Instance Method Summary collapse

Instance Method Details

#atom_bind(xml, property, mandatory = true) ⇒ Object

Binds a property against the matching child element in the specified atom entry xml source. The base node to look into is /entry/content



233
234
235
236
237
238
239
240
241
242
243
244
# File 'lib/rubyrest/atom.rb', line 233

def atom_bind( xml, property, mandatory = true )
  location = "/entry/content/#{property}"
  node = REXML::XPath.first( xml, location )
  if node == nil
    raise "no node found for location #{location}" if mandatory == true 
    return
  end
  if self.respond_to?( "#{property}=" )
    self.method( "#{property}=").call( node.text ) 
  else self[ property.intern ] = node.text end 

end