Class: Serega::SeregaValidations::Attribute::CheckBlock
- Inherits:
-
Object
- Object
- Serega::SeregaValidations::Attribute::CheckBlock
- Defined in:
- lib/serega/validations/attribute/check_block.rb
Overview
Attribute block parameter validator
Constant Summary collapse
- ERROR_MESSAGE =
Explains the changed attribute block behavior. Shown when the block looks like an old-style value block — it accepts parameters or defines no attributes.
"Attribute block now defines a nested serializer:" \ " it is executed in the context of a new serializer class and must define its attributes." \ " Defining the attribute value with a block is not supported anymore," \ " use the `value: <callable>` option instead."
Class Method Summary collapse
-
.call(block) ⇒ void
Checks block parameter provided with attribute.
Class Method Details
.call(block) ⇒ void
This method returns an undefined value.
Checks block parameter provided with attribute.
The block defines attributes of a nested anonymous serializer, so it is executed in the context of that serializer and must accept no parameters.
45 46 47 48 49 50 |
# File 'lib/serega/validations/attribute/check_block.rb', line 45 def call(block) return unless block signature = SeregaUtils::MethodSignature.call(block, pos_limit: 0) raise SeregaError, ERROR_MESSAGE unless signature == "0" end |