Class: Servus::Guards::TruthyGuard
- Inherits:
-
Servus::Guard
- Object
- Servus::Guard
- Servus::Guards::TruthyGuard
- Defined in:
- lib/servus/guards/truthy_guard.rb
Overview
Guard that ensures all specified attributes on an object are truthy.
Instance Attribute Summary
Attributes inherited from Servus::Guard
Instance Method Summary collapse
-
#test(on:, check:) ⇒ Boolean
Tests whether all specified attributes are truthy.
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(on:, check:) ⇒ Boolean
Tests whether all specified attributes are truthy.
30 31 32 |
# File 'lib/servus/guards/truthy_guard.rb', line 30 def test(on:, check:) Array(check).all? { |attr| !!on.public_send(attr) } end |