Class: ValidationErrorReporter::Error
- Inherits:
-
Object
- Object
- ValidationErrorReporter::Error
- Defined in:
- lib/validation_error_reporter/error.rb
Instance Attribute Summary collapse
-
#record ⇒ Object
readonly
Returns the value of attribute record.
Instance Method Summary collapse
-
#initialize(record) ⇒ Error
constructor
A new instance of Error.
- #model_name ⇒ Object
- #model_total_count ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(record) ⇒ Error
Returns a new instance of Error.
5 6 7 |
# File 'lib/validation_error_reporter/error.rb', line 5 def initialize(record) @record = record end |
Instance Attribute Details
#record ⇒ Object (readonly)
Returns the value of attribute record.
3 4 5 |
# File 'lib/validation_error_reporter/error.rb', line 3 def record @record end |
Instance Method Details
#model_name ⇒ Object
9 10 11 |
# File 'lib/validation_error_reporter/error.rb', line 9 def model_name record.class.model_name.name end |
#model_total_count ⇒ Object
13 14 15 |
# File 'lib/validation_error_reporter/error.rb', line 13 def model_total_count record.class.count end |
#to_s ⇒ Object
17 18 19 20 |
# File 'lib/validation_error_reporter/error.rb', line 17 def to_s "#{record.class.model_name.human} #{record.public_send(record.class.primary_key)}:\n" + record.errors..map {|e| " #{e}"}.join("\n") end |