diff --git a/modules/swagger-codegen/src/main/resources/ruby/partial_model_enum_class.mustache b/modules/swagger-codegen/src/main/resources/ruby/partial_model_enum_class.mustache index e0e1ca9403d..34df546ac86 100644 --- a/modules/swagger-codegen/src/main/resources/ruby/partial_model_enum_class.mustache +++ b/modules/swagger-codegen/src/main/resources/ruby/partial_model_enum_class.mustache @@ -1,4 +1,13 @@ 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) + consantValues = {{classname}}.constants.select{|c| c.to_s == value} + raise "Invalid ENUM value #{value} for class #{{{classname}}}" if consantValues.empty? + value + end end