Class: ActiveModel::BetterErrors::Errors
- Inherits:
-
Object
- Object
- ActiveModel::BetterErrors::Errors
show all
- Includes:
- Emulation
- Defined in:
- lib/active_model/better_errors/errors.rb
Overview
Constant Summary
Constants included
from Emulation
ActiveModel::BetterErrors::Emulation::MESSAGE_REPORTER_METHODS, ActiveModel::BetterErrors::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.
12
13
14
15
16
|
# File 'lib/active_model/better_errors/errors.rb', line 12
def initialize(base)
@base = base
@reporters = {}
@reporter_classes = reporter_classes
end
|
Instance Attribute Details
#base ⇒ Object
Returns the value of attribute base.
11
12
13
|
# File 'lib/active_model/better_errors/errors.rb', line 11
def base
@base
end
|
Instance Method Details
#array_reporter ⇒ Object
30
31
32
|
# File 'lib/active_model/better_errors/errors.rb', line 30
def array_reporter
get_reporter(:array)
end
|
#error_collection ⇒ Object
18
19
20
|
# File 'lib/active_model/better_errors/errors.rb', line 18
def error_collection
@error_collection ||= ErrorCollection.new(@base)
end
|
#get_reporter(type) ⇒ Object
43
44
45
46
47
|
# File 'lib/active_model/better_errors/errors.rb', line 43
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
53
54
55
56
|
# File 'lib/active_model/better_errors/errors.rb', line 53
def get_reporter_class(type)
type = type.to_s
@reporter_classes[type]
end
|
#hash_reporter ⇒ Object
26
27
28
|
# File 'lib/active_model/better_errors/errors.rb', line 26
def hash_reporter
get_reporter(:hash)
end
|
#message_reporter ⇒ Object
22
23
24
|
# File 'lib/active_model/better_errors/errors.rb', line 22
def message_reporter
get_reporter(:message)
end
|
#reporter_classes ⇒ Object
#set_reporter(type, reporter) ⇒ Object
34
35
36
37
38
39
40
41
|
# File 'lib/active_model/better_errors/errors.rb', line 34
def set_reporter(type, reporter)
type = type.to_s
klass = ::ActiveModel::BetterErrors
.get_reporter_class(type, reporter)
@reporter_classes[type] = klass
@reporters.delete type
end
|