Class: ActiveModel::DeprecationHandlingMessageArray

Inherits:
SimpleDelegator
  • Object
show all
Defined in:
activemodel/lib/active_model/errors.rb

Instance Method Summary collapse

Constructor Details

#initialize(content, errors, attribute) ⇒ DeprecationHandlingMessageArray

Returns a new instance of DeprecationHandlingMessageArray.


620
621
622
623
624
# File 'activemodel/lib/active_model/errors.rb', line 620

def initialize(content, errors, attribute)
  @errors = errors
  @attribute = attribute
  super(content.freeze)
end

Instance Method Details

#<<(message) ⇒ Object


626
627
628
629
630
631
632
# File 'activemodel/lib/active_model/errors.rb', line 626

def <<(message)
  ActiveSupport::Deprecation.warn("Calling `<<` to an ActiveModel::Errors message array in order to add an error is deprecated. Please call `ActiveModel::Errors#add` instead.")

  @errors.add(@attribute, message)
  __setobj__ @errors.messages_for(@attribute)
  self
end

#clearObject


634
635
636
637
638
# File 'activemodel/lib/active_model/errors.rb', line 634

def clear
  ActiveSupport::Deprecation.warn("Calling `clear` to an ActiveModel::Errors message array in order to delete all errors is deprecated. Please call `ActiveModel::Errors#delete` instead.")

  @errors.delete(@attribute)
end