lib/xml/mapping_extensions/typesafe_enum_node.rb
# Converts an enum value or value string to an enum instance
# @param xml_text [String, nil] the enum value or value string
# @return [TypesafeEnum::Base, nil] an instance of the enum class declared in the initializer,
#   or nil if `xml_text` is nil
Converts an enum value or value string to an enum instance
Converts an enum value or value string to an enum instance
def to_value(xml_text)
        return nil unless xml_text
        enum_instance = @enum_class.find_by_value(xml_text)
        enum_instance ||= @enum_class.find_by_value_str(xml_text)
        raise ArgumentError, "No instance of enum class #{@enum_class.name} found for value '#{xml_text}'" unless enum_instance
        enum_instance
      end
def to_value ( xml_text ) return nil unless xml_text enum_instance = @enum_class . find_by_value ( xml_text ) enum_instance ||= @enum_class . find_by_value_str ( xml_text ) raise ArgumentError , "No instance of enum class #{@enum_class.name} found for value '#{xml_text}'" unless enum_instance enum_instance end
Converts an enum value or value string to an enum instance
Converts an enum value or value string to an enum instance
an instance of the enum class declared in the initializer, or nil if `xml_text` is nil
an instance of the enum class declared in the initializer or nil if ` xml_text ` is nil
TypesafeEnum::Base, nil
xml_text
the enum value or value string
the enum value or value string