ruby-client.partial_model_enum_class.mustache Maven / Gradle / Ivy
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)
raise "Invalid ENUM value #{value} for class #{{{classname}}}"
end
end