Class: ActiveModel::ErrorCollecting::Errors
- Inherits:
-
Object
- Object
- ActiveModel::ErrorCollecting::Errors
show all
- Includes:
- Emulation
- Defined in:
- lib/active_model/error_collecting/errors.rb
Constant Summary
Constants included
from Emulation
ActiveModel::ErrorCollecting::Emulation::MESSAGE_REPORTER_METHODS, ActiveModel::ErrorCollecting::Emulation::MODEL_METHODS
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods included from Emulation
#add, #add_on_blank, #add_on_empty, #as_json, included, #to_xml
Constructor Details
#initialize(base) ⇒ Errors
Returns a new instance of Errors.
7
8
9
10
11
|
# File 'lib/active_model/error_collecting/errors.rb', line 7
def initialize(base)
@base = base
@reporters = {}
@reporter_classes = reporter_classes
end
|
Instance Attribute Details
#base ⇒ Object
Returns the value of attribute base.
6
7
8
|
# File 'lib/active_model/error_collecting/errors.rb', line 6
def base
@base
end
|
Instance Method Details
#array_reporter ⇒ Object
25
26
27
|
# File 'lib/active_model/error_collecting/errors.rb', line 25
def array_reporter
get_reporter(:array)
end
|
#error_collection ⇒ Object
13
14
15
|
# File 'lib/active_model/error_collecting/errors.rb', line 13
def error_collection
@error_collection ||= ErrorCollection.new(@base)
end
|
#get_reporter(type) ⇒ Object
36
37
38
39
40
|
# File 'lib/active_model/error_collecting/errors.rb', line 36
def get_reporter(type)
type = type.to_s
klass = get_reporter_class(type)
@reporters[type] = klass.new(error_collection)
end
|
#get_reporter_class(type) ⇒ Object
46
47
48
49
|
# File 'lib/active_model/error_collecting/errors.rb', line 46
def get_reporter_class(type)
type = type.to_s
@reporter_classes[type]
end
|
#hash_reporter ⇒ Object
21
22
23
|
# File 'lib/active_model/error_collecting/errors.rb', line 21
def hash_reporter
get_reporter(:hash)
end
|
#message_reporter ⇒ Object
17
18
19
|
# File 'lib/active_model/error_collecting/errors.rb', line 17
def message_reporter
get_reporter(:message)
end
|
#reporter_classes ⇒ Object
#set_reporter(type, reporter) ⇒ Object
29
30
31
32
33
34
|
# File 'lib/active_model/error_collecting/errors.rb', line 29
def set_reporter(type, reporter)
type = type.to_s
klass = ::ActiveModel::ErrorCollecting.get_reporter_class(type, reporter)
@reporter_classes[type] = klass
@reporters.delete type
end
|