Class: Assent::Errors
- Inherits:
-
Object
- Object
- Assent::Errors
- Includes:
- Config
- Defined in:
- lib/assent/validations/errors.rb
Instance Method Summary collapse
- #add(field, rule) ⇒ Object
- #errors ⇒ Object
-
#initialize ⇒ Errors
constructor
A new instance of Errors.
- #replace(text, field) ⇒ Object
Methods included from Config
Constructor Details
#initialize ⇒ Errors
Returns a new instance of Errors.
7 8 9 10 |
# File 'lib/assent/validations/errors.rb', line 7 def initialize @errors = Hash.new super end |
Instance Method Details
#add(field, rule) ⇒ Object
12 13 14 15 16 17 |
# File 'lib/assent/validations/errors.rb', line 12 def add(field, rule) text = String.new(Config.config[rule.to_s]) replace(text, field) @errors[field] ||= [] @errors[field].push(text) end |
#errors ⇒ Object
19 20 21 |
# File 'lib/assent/validations/errors.rb', line 19 def errors @errors end |
#replace(text, field) ⇒ Object
23 24 25 26 |
# File 'lib/assent/validations/errors.rb', line 23 def replace(text, field) = text.sub! ':field', field.to_s return end |