Class: PolicyCheck::ErrorList
- Inherits:
-
Object
- Object
- PolicyCheck::ErrorList
- Defined in:
- lib/policy_check/error_list.rb
Overview
Create a summary error model and summarize the decision
Instance Method Summary collapse
-
#error_messages ⇒ Array<String>
Error messages.
-
#initialize(model, &block) ⇒ ErrorList
constructor
A new instance of ErrorList.
-
#valid? ⇒ Boolean
True if all errors are false.
Constructor Details
#initialize(model, &block) ⇒ ErrorList
Returns a new instance of ErrorList.
8 9 10 11 12 |
# File 'lib/policy_check/error_list.rb', line 8 def initialize(model, &block) @model = model @block = block @errors = instance_eval(&block) end |
Instance Method Details
#error_messages ⇒ Array<String>
Returns error messages.
20 21 22 |
# File 'lib/policy_check/error_list.rb', line 20 def errors.map(&:error_message).compact end |
#valid? ⇒ Boolean
Returns true if all errors are false.
15 16 17 |
# File 'lib/policy_check/error_list.rb', line 15 def valid? errors.none?(&:error?) end |