Sha256: 28f901fa5739aabafc048d5c33a38c03be33886877256608d8b24f6af119a8b2

Contents?: true

Size: 723 Bytes

Versions: 50

Compression:

Stored size: 723 Bytes

Contents

  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 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)
      constantValues = {{classname}}.constants.select { |c| {{classname}}::const_get(c) == value }
      raise "Invalid ENUM value #{value} for class #{{{classname}}}" if constantValues.empty?
      value
    end
  end

Version data entries

50 entries across 50 versions & 6 rubygems

Version Path
mux_ruby-3.20.0 gen/templates/partial_model_enum_class.mustache
mux_ruby-3.19.0 gen/templates/partial_model_enum_class.mustache
mux_ruby-3.18.0 gen/templates/partial_model_enum_class.mustache
mux_ruby-3.17.0 gen/templates/partial_model_enum_class.mustache
dropbox-sign-1.4.1 templates/partial_model_enum_class.mustache
ruby-linstor-client-1.1.1 generator/template/partial_model_enum_class.mustache
mux_ruby-3.15.0 gen/templates/partial_model_enum_class.mustache
dropbox-sign-1.4.0 templates/partial_model_enum_class.mustache
mux_ruby-3.14.0 gen/templates/partial_model_enum_class.mustache
dropbox-sign-1.3.0 templates/partial_model_enum_class.mustache
kuapir-0.1.4 openapi-generator-templates/partial_model_enum_class.mustache
mux_ruby-3.13.0 gen/templates/partial_model_enum_class.mustache
mux_ruby-3.12.0 gen/templates/partial_model_enum_class.mustache
kuapir-0.1.3 openapi-generator-templates/partial_model_enum_class.mustache
mux_ruby-3.11.1 gen/templates/partial_model_enum_class.mustache
mux_ruby-3.11.0 gen/templates/partial_model_enum_class.mustache
dropbox-sign-1.2.0 templates/partial_model_enum_class.mustache
dropbox-sign-1.1.2 templates/partial_model_enum_class.mustache
dropbox-sign-1.1.1 templates/partial_model_enum_class.mustache
dropbox-sign-1.1.0 templates/partial_model_enum_class.mustache