YAML::add_private_type Method
add_private_type
Adds a user-level private type to the parser

YAML::add_private_type(
  (Regexp or String) type_re,
  Proc transfer_proc
)

Parameters
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 private type.
Block Parameters
type
The type string of the element being parsed.
val
The value of the YAML element being coerced into this private type.
Return Values
None

Details

Private types are intended to be a quick and informal typing mechanism. If, for example, you have a Hash that is storing employee data, but you want to be able to mark the Hash as containing structured employee data, you could give the Hash an '!!EmployeeList' private type, without needing any type of Ruby internal type to back it up.

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

Often, for simple private types, you don't even need to use the YAML::add_private_type method. Any private types found by the parser which aren't registered become objects of the PrivateType class, another convenient way of handling these special creatures.