Class: Serega::SeregaPlugins::Metadata::MetaAttribute::CheckBlock
- Inherits:
-
Object
- Object
- Serega::SeregaPlugins::Metadata::MetaAttribute::CheckBlock
- Defined in:
- lib/serega/plugins/metadata/validations/check_block.rb
Overview
Validator for meta_attribute block parameter
Class Method Summary collapse
-
.call(block) ⇒ void
Checks block provided with attribute Block must have up to two arguments - object and context.
Class Method Details
.call(block) ⇒ void
This method returns an undefined value.
Checks block provided with attribute Block must have up to two arguments - object and context. It should not have any *rest or **key arguments
35 36 37 38 39 40 41 42 |
# File 'lib/serega/plugins/metadata/validations/check_block.rb', line 35 def call(block) raise SeregaError, "Block must be provided when defining meta attribute" unless block params = block.parameters return if (params.count <= 2) && params.all? { |par| ALLOWED_PARAM_TYPES.include?(par[0]) } raise SeregaError, "Block can have maximum 2 regular parameters (no **keyword or *array args)" end |