github.com/phrase/openapi@v0.0.0-20240514140800-49e8a106740e/openapi-generator/templates/ruby-client/partial_model_enum_class.mustache (about) 1 class {{classname}}{{#allowableValues}}{{#enumVars}} 2 {{{name}}} = {{{value}}}.freeze{{/enumVars}} 3 4 {{/allowableValues}} 5 # Builds the enum from string 6 # @param [String] The enum value in the form of the string 7 # @return [String] The enum value 8 def self.build_from_hash(value) 9 new.build_from_hash(value) 10 end 11 12 # Builds the enum from string 13 # @param [String] The enum value in the form of the string 14 # @return [String] The enum value 15 def build_from_hash(value) 16 constantValues = {{classname}}.constants.select { |c| {{classname}}::const_get(c) == value } 17 raise "Invalid ENUM value #{value} for class #{{{classname}}}" if constantValues.empty? 18 value 19 end 20 end