handlebars.ruby.partial_model_enum_class.mustache Maven / Gradle / Ivy
class {{classname}}
{{#allowableValues}}
{{#enumVars}}
{{{name}}} = {{{value}}}.freeze
{{/enumVars}}
{{/allowableValues}}
# 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)
constantValues = {{classname}}.constants.select { |c| {{classname}}::const_get(c) == value }
raise "Invalid ENUM value #{value} for class #{{{classname}}}" if constantValues.empty?
value
end
end