Class: PolicyCheck::ErrorList
- Inherits:
-
Object
- Object
- PolicyCheck::ErrorList
- Defined in:
- lib/policy_check/error_list.rb
Overview
A model that summarizes the errors defined in the #policy block
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 13 |
# 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.
21 22 23 |
# File 'lib/policy_check/error_list.rb', line 21 def errors.map(&:error_message).compact end |
#valid? ⇒ Boolean
Returns true if all errors are false.
16 17 18 |
# File 'lib/policy_check/error_list.rb', line 16 def valid? errors.none?(&:error?) end |