Module: WADL::XMLRepresentation
- Defined in:
- lib/wadl/xml_representation.rb
Overview
A module mixed in to REXML documents to make them representations in the WADL sense.
Instance Method Summary (collapse)
-
- (Object) each_by_param(param_name)
Yields up each XML element for the given Param object.
-
- (Object) get_by_param(param_name)
Returns an XML element for the given Param object.
- - (Object) lookup_param(name)
- - (Object) representation_of(format)
Instance Method Details
- (Object) each_by_param(param_name)
Yields up each XML element for the given Param object.
53 54 55 |
# File 'lib/wadl/xml_representation.rb', line 53 def each_by_param(param_name) REXML::XPath.each(self, lookup_param(param_name).path) { |e| yield e } end |
- (Object) get_by_param(param_name)
Returns an XML element for the given Param object.
58 59 60 |
# File 'lib/wadl/xml_representation.rb', line 58 def get_by_param(param_name) REXML::XPath.first(self, lookup_param(param_name).path) end |
- (Object) lookup_param(name)
43 44 45 46 47 48 49 50 |
# File 'lib/wadl/xml_representation.rb', line 43 def lookup_param(name) param = @params.find { |p| p.name == name } raise ArgumentError, "No such param #{name}" unless param raise ArgumentError, "Param #{name} has no path!" unless param.path param end |
- (Object) representation_of(format)
39 40 41 |
# File 'lib/wadl/xml_representation.rb', line 39 def representation_of(format) @params = format.params end |