Class: TransForms::FormErrors
- Inherits:
-
Object
- Object
- TransForms::FormErrors
show all
- Defined in:
- lib/trans_forms/form_errors.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(form_model, original) ⇒ FormErrors
Returns a new instance of FormErrors.
5
6
7
|
# File 'lib/trans_forms/form_errors.rb', line 5
def initialize(form_model, original)
self.form_model, self.original = form_model, original
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(m, *args, &block) ⇒ Object
33
34
35
|
# File 'lib/trans_forms/form_errors.rb', line 33
def method_missing(m, *args, &block)
original.send(m, *args, &block)
end
|
Instance Attribute Details
Returns the value of attribute form_model.
3
4
5
|
# File 'lib/trans_forms/form_errors.rb', line 3
def form_model
@form_model
end
|
#original ⇒ Object
Returns the value of attribute original.
3
4
5
|
# File 'lib/trans_forms/form_errors.rb', line 3
def original
@original
end
|
Instance Method Details
#[](key) ⇒ Object
23
24
25
26
27
|
# File 'lib/trans_forms/form_errors.rb', line 23
def [](key)
error_models.inject([]) { |acc, error_model|
acc += (error_model[key])
}
end
|
#clear ⇒ Object
17
18
19
20
21
|
# File 'lib/trans_forms/form_errors.rb', line 17
def clear
error_models.each do |em|
em.clear
end
end
|
#empty? ⇒ Boolean
29
30
31
|
# File 'lib/trans_forms/form_errors.rb', line 29
def empty?
error_models.all?(&:empty?)
end
|
#error_models ⇒ Object
9
10
11
|
# File 'lib/trans_forms/form_errors.rb', line 9
def error_models
[original, form_model.main_instance.try(:errors)].compact
end
|
#full_messages ⇒ Object
13
14
15
|
# File 'lib/trans_forms/form_errors.rb', line 13
def full_messages
original.full_messages
end
|