Module: Ldbws::ResponseTypes::ParsingFunctions

Included in:
Base
Defined in:
lib/ldbws/response_types/parsing_functions.rb

Overview

Provides a DSL-type interface for easily defining the conversion from XML to PORO.

It does this through the provision of two methods: #property, which defines a single property of a specified type, and #collection which defines a list of the same.

Thus, given some XML like:

<foo>text</foo>
<bar>
  <value>one</value>
  <value>two</value>
  <value>three</value>
</bar>

Your DSL would look something like:

property :foo, String
collection :bar, "Value", String

Nested parsing

Both [#property] and [#collection] take a class that is used to convert from the XML value to Ruby. This can be any normal Ruby class that response to either #new or #parse (like [Date]). Additionally, this can be another class implementing this module, in which case the #from_xml method is used.

Defined Under Namespace

Modules: ClassFunctions

Class Method Summary collapse

Class Method Details

.included(base) ⇒ Object

:nodoc:



27
28
29
# File 'lib/ldbws/response_types/parsing_functions.rb', line 27

def self.included(base)
  base.extend(ClassFunctions)
end