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