Class: Servus::Guards::PresenceGuard
- Inherits:
-
Servus::Guard
- Object
- Servus::Guard
- Servus::Guards::PresenceGuard
- Defined in:
- lib/servus/guards/presence_guard.rb
Overview
Guard that ensures all provided values are present (not nil or empty).
This is a flexible guard that accepts any number of keyword arguments and validates that all values are present.
Instance Attribute Summary
Attributes inherited from Servus::Guard
Instance Method Summary collapse
-
#test(**values) ⇒ Boolean
Tests whether all provided values are present.
Methods inherited from Servus::Guard
derive_method_name, #error, error_code, execute!, execute?, http_status, inherited, #initialize, message, #message, #method_missing, register_guard_methods, #respond_to_missing?
Constructor Details
This class inherits a constructor from Servus::Guard
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Servus::Guard
Instance Method Details
#test(**values) ⇒ Boolean
Tests whether all provided values are present.
A value is considered present if it is not nil and not empty (for values that respond to empty?).
43 44 45 |
# File 'lib/servus/guards/presence_guard.rb', line 43 def test(**values) values.all? { |_, value| present?(value) } end |