YAML::add_domain_type Method
add_domain_type
Adds a user-level domain type to the parser

YAML::add_domain_type(
  String domain_and_date,
  (Regexp or String) type_re,
  Proc transfer_proc
)

Parameters
domain_and_date
The domain and date (seperated by a comma) to assign the type under. An example for a personal type would be 'your-company.com,2002-09-23'. The date can usually be just a year, representing the first day of year ('2002' == '2002-01-01'). First day of the month can be shortened to just year and month ('2002-09' == '2002-09-01'). See http://www.taguri.org/ for details on this convention.
type_re
A regular expression to match type names with. If a String, the exact name of the type to add.
transfer_proc
A procedure for translating the YAML element into the domain type.
Block Parameters
type
The full domain type string of the element being parsed.
val
The value of the YAML element being coerced into this domain type.
Return Values
None

Details

The add_domain_type method allows you to register your own domain-specific types to YAML's typing mechanism. The domain string should contain a tag-uri domain (with the domain name and date separated by a comma).

YAML.add_domain_type( "hospital.com,2003", "Med" ) do |type, val|
  Medication.new( val )
end
Ex. 46: Adding a Domain Type