Module: ActiveInteraction::Errors::Details
- Extended by:
- ActiveSupport::Concern
- Included in:
- ActiveInteraction::Errors
- Defined in:
- lib/active_interaction/backports.rb
Overview
Required for Rails < 5.
Extracted from active_model-errors_details 1.2.0. Modified to add support for ActiveModel 3.2.0.
Instance Method Summary collapse
- #add_with_details(attribute, message = :invalid, options = {}) ⇒ Object
- #clear_with_details ⇒ Object
- #delete_with_details(attribute) ⇒ Object
- #initialize_dup_with_details(other) ⇒ Object
- #initialize_with_details(base) ⇒ Object
Instance Method Details
#add_with_details(attribute, message = :invalid, options = {}) ⇒ Object
38 39 40 41 42 43 44 45 |
# File 'lib/active_interaction/backports.rb', line 38 def add_with_details(attribute, = :invalid, = {}) = .call if .respond_to?(:call) error = .except(*CALLBACKS_OPTIONS + MESSAGE_OPTIONS) .merge(error: ) details[attribute].push(error) add_without_details(attribute, , ) end |
#clear_with_details ⇒ Object
47 48 49 50 |
# File 'lib/active_interaction/backports.rb', line 47 def clear_with_details details.clear clear_without_details end |
#delete_with_details(attribute) ⇒ Object
52 53 54 55 |
# File 'lib/active_interaction/backports.rb', line 52 def delete_with_details(attribute) details.delete(attribute) delete_without_details(attribute) end |
#initialize_dup_with_details(other) ⇒ Object
33 34 35 36 |
# File 'lib/active_interaction/backports.rb', line 33 def initialize_dup_with_details(other) @details = other.details.deep_dup initialize_dup_without_details(other) end |
#initialize_with_details(base) ⇒ Object
28 29 30 31 |
# File 'lib/active_interaction/backports.rb', line 28 def initialize_with_details(base) @details = Hash.new { |details, attribute| details[attribute] = [] } initialize_without_details(base) end |