Class: Serega::SeregaValidations::Attribute::CheckOptBaseSerializer
- Inherits:
-
Object
- Object
- Serega::SeregaValidations::Attribute::CheckOptBaseSerializer
- Defined in:
- lib/serega/validations/attribute/check_opt_base_serializer.rb
Overview
Attribute :base_serializer option validator
Class Method Summary collapse
-
.call(opts, block = nil) ⇒ void
Checks attribute :base_serializer option.
Class Method Details
.call(opts, block = nil) ⇒ void
This method returns an undefined value.
Checks attribute :base_serializer option. It specifies the parent class for the nested serializer defined with the attribute block, so it makes sense only when a block is provided.
26 27 28 29 30 31 32 33 34 35 |
# File 'lib/serega/validations/attribute/check_opt_base_serializer.rb', line 26 def call(opts, block = nil) return unless opts.key?(:base_serializer) raise SeregaError, "Option :base_serializer can be used only with a block" unless block value = opts[:base_serializer] return if value.is_a?(Class) && (value <= Serega) raise SeregaError, "Invalid option :base_serializer => #{value.inspect}. Must be a Serega subclass" end |