Class: RubyRest::Atom::Document
- Inherits:
-
REXML::Document
- Object
- REXML::Document
- RubyRest::Atom::Document
- Defined in:
- lib/rubyrest/atom.rb
Overview
Ruby-on-Rest specialization of the REXML document class. Adds some convenient ways of accessing data from a Atom document
Instance Method Summary collapse
-
#clone ⇒ Object
Overrides the default implementation by returning a new Ruby-on-Rest Atom Document.
-
#get_value(name, required = true) ⇒ Object
Resolves the missing method into a content property and returns its text value.
-
#id ⇒ Object
Shortcut for the id element contained within the content.
- #method_missing(name, *args) ⇒ Object
- #set_value(name, value) ⇒ Object
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args) ⇒ Object
24 25 26 |
# File 'lib/rubyrest/atom.rb', line 24 def method_missing( name, *args ) get_value( name ) end |
Instance Method Details
#clone ⇒ Object
Overrides the default implementation by returning a new Ruby-on-Rest Atom Document
49 50 51 |
# File 'lib/rubyrest/atom.rb', line 49 def clone self.class.new self.to_s end |
#get_value(name, required = true) ⇒ Object
Resolves the missing method into a content property and returns its text value
30 31 32 33 34 35 |
# File 'lib/rubyrest/atom.rb', line 30 def get_value( name, required=true ) location = "/entry/rubyrest:content/#{name}" value = text( location ) raise "missing value at location #{location} in #{self.to_s}" if required && !value return value end |
#id ⇒ Object
Shortcut for the id element contained within the content.
43 44 45 |
# File 'lib/rubyrest/atom.rb', line 43 def id text( "/entry/rubyrest:content/id" ) end |
#set_value(name, value) ⇒ Object
37 38 39 |
# File 'lib/rubyrest/atom.rb', line 37 def set_value( name, value ) get_text( "/entry/rubyrest:content/#{name}" ).value = value end |