Class: Dry::Schema::Macros::Filled

Inherits:
Value show all
Defined in:
lib/dry/schema/macros/filled.rb

Overview

Macro used to prepend ‘:filled?` predicate

Instance Method Summary collapse

Methods inherited from Value

#respond_to_missing?

Methods inherited from DSL

#each, #filled, #schema, #value

Methods inherited from Core

#new, #operation, #to_ast, #to_rule

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Dry::Schema::Macros::Value

Instance Method Details

#call(*args, &block) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
# File 'lib/dry/schema/macros/filled.rb', line 10

def call(*args, &block)
  if args.include?(:empty?)
    raise ::Dry::Schema::InvalidSchemaError, "Using filled with empty? predicate is invalid"
  end

  if args.include?(:filled?)
    raise ::Dry::Schema::InvalidSchemaError, "Using filled with filled? is redundant"
  end

  value(:filled?, *args, &block)
end