Class: Form::ActiveModel::Validations::Result::ResultErrors
- Inherits:
-
Reform::Contract::Result::Errors
- Object
- Reform::Contract::Result::Errors
- Form::ActiveModel::Validations::Result::ResultErrors
show all
- Defined in:
- lib/reform/form/active_model/validations.rb
Overview
to expose via #errors. i hate it.
Instance Method Summary
collapse
Constructor Details
#initialize(a, b, success, amv_errors) ⇒ ResultErrors
Returns a new instance of ResultErrors.
125
126
127
128
129
|
# File 'lib/reform/form/active_model/validations.rb', line 125
def initialize(a, b, success, amv_errors)
super(a, b)
@success = success
@amv_errors = amv_errors
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(m, *args, &block) ⇒ Object
161
162
163
|
# File 'lib/reform/form/active_model/validations.rb', line 161
def method_missing(m, *args, &block)
@amv_errors.send(m, *args, &block) end
|
Instance Method Details
#[](k) ⇒ Object
135
136
137
|
# File 'lib/reform/form/active_model/validations.rb', line 135
def [](k)
super(k.to_sym) || []
end
|
#add(key, error_text) ⇒ Object
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
|
# File 'lib/reform/form/active_model/validations.rb', line 144
def add(key, error_text)
error = @amv_errors.add(key, error_text)
error = [error.message] unless error.is_a?(Array)
Reform::Contract::CustomError.new(key, error_text, @result.to_results)
@dotted_errors.key?(key) ? @dotted_errors[key] |= error : @dotted_errors[key] = error
instance_variable_set(:@dotted_errors, @dotted_errors)
end
|
#empty? ⇒ Boolean
131
132
133
|
# File 'lib/reform/form/active_model/validations.rb', line 131
def empty?
@success
end
|
#full_messages ⇒ Object
170
171
172
173
174
175
176
|
# File 'lib/reform/form/active_model/validations.rb', line 170
def full_messages
base_errors = @amv_errors.full_messages
form_fields = @amv_errors.instance_variable_get(:@base).instance_variable_get(:@fields)
nested_errors = full_messages_for_nested_fields(form_fields)
[base_errors, nested_errors].flatten.compact
end
|
#respond_to?(method, include_all = false) ⇒ Boolean
166
167
168
|
# File 'lib/reform/form/active_model/validations.rb', line 166
def respond_to?(method, include_all = false)
@amv_errors.respond_to?(method, include_all) ? true : super
end
|
#to_s ⇒ Object
rails expects this to return a stringified hash of the messages
140
141
142
|
# File 'lib/reform/form/active_model/validations.rb', line 140
def to_s
messages.to_s
end
|