lib/svix/models/statistics_period.rb in svix-1.38.0 vs lib/svix/models/statistics_period.rb in svix-1.39.0

- old
+ new

@@ -4,11 +4,11 @@ #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) The version of the OpenAPI document: 1.1.1 Generated by: https://openapi-generator.tech -OpenAPI Generator version: 5.2.0 +Generator version: 7.9.0 =end require 'date' require 'time' @@ -16,10 +16,14 @@ module Svix class StatisticsPeriod ONE_DAY = "OneDay".freeze FIVE_MINUTES = "FiveMinutes".freeze + def self.all_vars + @all_vars ||= [ONE_DAY, FIVE_MINUTES].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) @@ -27,11 +31,10 @@ # 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 = StatisticsPeriod.constants.select { |c| StatisticsPeriod::const_get(c) == value } - raise "Invalid ENUM value #{value} for class #StatisticsPeriod" if constantValues.empty? - value + return value if StatisticsPeriod.all_vars.include?(value) + raise "Invalid ENUM value #{value} for class #StatisticsPeriod" end end end