Class: Schema::Errors
- Inherits:
-
Object
- Object
- Schema::Errors
- Defined in:
- lib/schema/errors.rb
Overview
Schema::Errors used internally for testing mainly, recommend using ActiveModel::Validations
Constant Summary collapse
- EMPTY_ARRAY =
[].freeze
Instance Attribute Summary collapse
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
Instance Method Summary collapse
- #[](name) ⇒ Object
- #add(name, error) ⇒ Object (also: #[]=)
- #empty? ⇒ Boolean
-
#initialize ⇒ Errors
constructor
A new instance of Errors.
Constructor Details
#initialize ⇒ Errors
Returns a new instance of Errors.
10 11 12 |
# File 'lib/schema/errors.rb', line 10 def initialize @errors = {} end |
Instance Attribute Details
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
6 7 8 |
# File 'lib/schema/errors.rb', line 6 def errors @errors end |
Instance Method Details
#[](name) ⇒ Object
14 15 16 |
# File 'lib/schema/errors.rb', line 14 def [](name) @errors[name] || EMPTY_ARRAY end |
#add(name, error) ⇒ Object Also known as: []=
18 19 20 21 |
# File 'lib/schema/errors.rb', line 18 def add(name, error) @errors[name] ||= [] @errors[name] << error end |
#empty? ⇒ Boolean
24 25 26 |
# File 'lib/schema/errors.rb', line 24 def empty? @errors.empty? end |