Sha256: ea443c225b1fa12d2fb8ff0807d421a2f19de54613dd385d2623409134a0db28

Contents?: true

Size: 438 Bytes

Versions: 12

Compression:

Stored size: 438 Bytes

Contents

ActiveModel::Errors.class_eval do
  def <<(other)
    copy_messages_from(other)
    copy_details_from(other) if respond_to?(:details)

    self
  end

  private

  def copy_details_from(other)
    details.merge!(other.details) do |_, val_one, val_two|
      [*val_one] + [*val_two]
    end
  end

  def copy_messages_from(other)
    messages.merge!(other.messages) do |_, val_one, val_two|
      [*val_one] + [*val_two]
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
railjet-3.2.0 lib/active_model/merge_errors.rb
railjet-3.1.0 lib/active_model/merge_errors.rb
railjet-3.0.0 lib/active_model/merge_errors.rb
railjet-2.1.1 lib/active_model/merge_errors.rb
railjet-2.1 lib/active_model/merge_errors.rb
railjet-2.0 lib/active_model/merge_errors.rb
railjet-2.0.pre4 lib/active_model/merge_errors.rb
railjet-2.0.pre3 lib/active_model/merge_errors.rb
railjet-2.0.pre2 lib/active_model/merge_errors.rb
railjet-2.0.pre1 lib/active_model/merge_errors.rb
railjet-2.0.pre lib/active_model/merge_errors.rb
railjet-1.0.1 lib/active_model/merge_errors.rb