Class: Exekutor::Configuration::SerializerValidator
- Inherits:
-
Object
- Object
- Exekutor::Configuration::SerializerValidator
- Defined in:
- lib/exekutor/configuration.rb
Overview
Validates the value for a serializer, which must implement dump & load
Class Method Summary collapse
-
.convert!(serializer) ⇒ #dump&#load
Tries to convert the specified value to a serializer, raises an error if the conversion fails.
-
.valid?(serializer) ⇒ Boolean
Whether the serializer has implemented dump & load.
Class Method Details
.convert!(serializer) ⇒ #dumpload
Tries to convert the specified value to a serializer, raises an error if the conversion fails.
387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 |
# File 'lib/exekutor/configuration.rb', line 387 def self.convert!(serializer) return serializer if SerializerValidator.valid? serializer if serializer.respond_to?(:call) serializer = serializer.call return serializer if SerializerValidator.valid? serializer end if serializer.respond_to?(:new) serializer = serializer.new return serializer if SerializerValidator.valid? serializer end raise Error, <<~MSG.squish The configured serializer (#{serializer.class}) does not respond to #dump and #load MSG end |
.valid?(serializer) ⇒ Boolean
Returns whether the serializer has implemented dump & load.
379 380 381 |
# File 'lib/exekutor/configuration.rb', line 379 def self.valid?(serializer) serializer.respond_to?(:dump) && serializer.respond_to?(:load) end |