Sha256: 17850e8942c1bd5b0e17e7c8a1712cebb0ccd7f1859e8fd31a23c953b7f52dbb

Contents?: true

Size: 807 Bytes

Versions: 6

Compression:

Stored size: 807 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

6 entries across 6 versions & 2 rubygems

Version Path
clerk-http-client-1.0.0 resources/templates/partial_model_enum_class.mustache
clerk-http-client-0.0.1 resources/templates/partial_model_enum_class.mustache
dropbox-sign-1.8.0 templates/partial_model_enum_class.mustache
dropbox-sign-1.7.0 templates/partial_model_enum_class.mustache
dropbox-sign-1.6.1 templates/partial_model_enum_class.mustache
dropbox-sign-1.6.0 templates/partial_model_enum_class.mustache