Class: Notifications::UuidValidator
- Inherits:
-
Object
- Object
- Notifications::UuidValidator
- Defined in:
- lib/notifications/client/uuid_validator.rb
Constant Summary collapse
Instance Attribute Summary collapse
-
#uuid ⇒ Object
Returns the value of attribute uuid.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(uuid) ⇒ UuidValidator
constructor
A new instance of UuidValidator.
- #valid? ⇒ Boolean
Constructor Details
#initialize(uuid) ⇒ UuidValidator
Returns a new instance of UuidValidator.
8 9 10 |
# File 'lib/notifications/client/uuid_validator.rb', line 8 def initialize(uuid) self.uuid = uuid end |
Instance Attribute Details
#uuid ⇒ Object
Returns the value of attribute uuid.
6 7 8 |
# File 'lib/notifications/client/uuid_validator.rb', line 6 def uuid @uuid end |
Class Method Details
.validate!(uuid, contextual_message = nil) ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'lib/notifications/client/uuid_validator.rb', line 16 def self.validate!(uuid, = nil) return if new(uuid).valid? = "#{uuid.inspect} is not a valid uuid" += "\n#{}" if raise ArgumentError, end |
Instance Method Details
#valid? ⇒ Boolean
12 13 14 |
# File 'lib/notifications/client/uuid_validator.rb', line 12 def valid? !!(uuid && uuid.match(REGEX)) end |