Class: Filterameter::DeclarationsValidator
- Inherits:
-
Object
- Object
- Filterameter::DeclarationsValidator
- Includes:
- Errors
- Defined in:
- lib/filterameter/declarations_validator.rb
Overview
# Declarations Validator
Class DeclarationsValidtor fetches each filter and sort from the registry to validate the declaration. This class can be accessed from the controller as ‘declarations_validator` (via the FilterCoordinator) and be used in tests.
Use the ‘valid?` method to test, then report errors with the `errors` attribute.
A test in RSpec might look like this:
expect(WidgetsController.declarations_validator).to be_valid
In Minitest it might look like this:
validator = WidgetsController.declarations_validator
assert_predicate validator, :valid?, -> { validator.errors }
Defined Under Namespace
Classes: FactoryErrors
Instance Method Summary collapse
- #errors ⇒ Object
-
#initialize(controller_name, model, registry) ⇒ DeclarationsValidator
constructor
A new instance of DeclarationsValidator.
- #inspect ⇒ Object
Methods included from Errors
Constructor Details
#initialize(controller_name, model, registry) ⇒ DeclarationsValidator
Returns a new instance of DeclarationsValidator.
22 23 24 25 26 |
# File 'lib/filterameter/declarations_validator.rb', line 22 def initialize(controller_name, model, registry) @controller_name = controller_name @model = model @registry = registry end |
Instance Method Details
#errors ⇒ Object
32 33 34 |
# File 'lib/filterameter/declarations_validator.rb', line 32 def errors @errors&.join("\n") end |
#inspect ⇒ Object
28 29 30 |
# File 'lib/filterameter/declarations_validator.rb', line 28 def inspect "filter declarations on #{@controller_name.titleize}Controller" end |