Sha256: 38f6f0ef52e8919743779bb1a49c475817d33db874446db10f9ca98251af5f1e

Contents?: true

Size: 808 Bytes

Versions: 1

Compression:

Stored size: 808 Bytes

Contents

  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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
dropbox-sign-1.5.0 templates/partial_model_enum_class.mustache