Class: OneSignal::Notification::EnumAttributeValidator

Inherits:
Object
  • Object
show all
Defined in:
lib/onesignal/models/notification.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(datatype, allowable_values) ⇒ EnumAttributeValidator

Returns a new instance of EnumAttributeValidator.



351
352
353
354
355
356
357
358
359
360
361
362
# File 'lib/onesignal/models/notification.rb', line 351

def initialize(datatype, allowable_values)
  @allowable_values = allowable_values.map do |value|
    case datatype.to_s
    when /Integer/i
      value.to_i
    when /Float/i
      value.to_f
    else
      value
    end
  end
end

Instance Attribute Details

#allowable_valuesObject (readonly)

Returns the value of attribute allowable_values.



349
350
351
# File 'lib/onesignal/models/notification.rb', line 349

def allowable_values
  @allowable_values
end

#datatypeObject (readonly)

Returns the value of attribute datatype.



348
349
350
# File 'lib/onesignal/models/notification.rb', line 348

def datatype
  @datatype
end

Instance Method Details

#valid?(value) ⇒ Boolean

Returns:

  • (Boolean)


364
365
366
# File 'lib/onesignal/models/notification.rb', line 364

def valid?(value)
  !value || allowable_values.include?(value)
end