Sha256: bdec399941252396043b6834a68ee57b798a6b1d064c517ae710f592c9624819
Contents?: true
Size: 552 Bytes
Versions: 2
Compression:
Stored size: 552 Bytes
Contents
require_relative 'node_base' require 'ruby-enum' module XML module MappingExtensions # Base class for single-attribute nodes with `Ruby::Enum` values # # Usage: # - extend this class # - add an `ENUM_CLASS` constant whose value is the `Ruby::Enum` class # to be mapped # - call `::XML::Mapping.add_node_class` to add your new node class class EnumNodeBase < NodeBase def to_value(xml_text) enum_class = self.class::ENUM_CLASS enum_class.parse(xml_text) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
xml-mapping_extensions-0.1.1 | lib/xml/mapping_extensions/enum_node_base.rb |
xml-mapping_extensions-0.1.0 | lib/xml/mapping_extensions/enum_node_base.rb |