  class {{classname}}{{#allowableValues}}{{#enumVars}}
    {{{name}}} = {{{value}}}.freeze{{/enumVars}}

{{/allowableValues}}
    def self.all_vars
      @all_vars ||= [{{#allowableValues}}{{#enumVars}}{{{name}}}{{^-last}}, {{/-last}}{{/enumVars}}{{/allowableValues}}].freeze
    end

    # Builds the enum from string
    # @param [String] The enum value in the form of the string
    # @return [String] The enum value
    def self.build_from_hash(value)
      new.build_from_hash(value)
    end

    # Builds the enum from string
    # @param [String] The enum value in the form of the string
    # @return [String] The enum value
    def build_from_hash(value)
      return value if {{classname}}.all_vars.include?(value)
{{#enumUnknownDefaultCase}}
      {{#allowableValues}}{{#enumVars}}{{#-last}}{{{name}}}{{/-last}}{{/enumVars}}{{/allowableValues}}
{{/enumUnknownDefaultCase}}
{{^enumUnknownDefaultCase}}
      raise "Invalid ENUM value #{value} for class #{{{classname}}}"
{{/enumUnknownDefaultCase}}
    end
  end