Class: ActiveModel::BetterErrors::ErrorMessageSet

Inherits:
Array
  • Object
show all
Defined in:
lib/active_model/better_errors/error_message_set.rb

Overview

ErrorMessageSet

Instance Method Summary collapse

Constructor Details

#initialize(base, attribute, errors = []) ⇒ ErrorMessageSet

Returns a new instance of ErrorMessageSet.



9
10
11
12
13
14
15
# File 'lib/active_model/better_errors/error_message_set.rb', line 9

def initialize(base, attribute, errors = [])
  @base      = base
  @attribute = attribute
  errors.each do |error|
    push(*error)
  end
end

Instance Method Details

#<<(error) ⇒ Object



17
18
19
# File 'lib/active_model/better_errors/error_message_set.rb', line 17

def <<(error)
  super ErrorMessage.build(@base, @attribute, *error)
end

#[]=(index, error) ⇒ Object



25
26
27
# File 'lib/active_model/better_errors/error_message_set.rb', line 25

def []=(index, error)
  super index, ErrorMessage.build(@base, @attribute, *error)
end

#insert(index, error) ⇒ Object



29
30
31
# File 'lib/active_model/better_errors/error_message_set.rb', line 29

def insert(index, error)
  super index, ErrorMessage.build(@base, @attribute, *error)
end

#push(message, options = {}) ⇒ Object



21
22
23
# File 'lib/active_model/better_errors/error_message_set.rb', line 21

def push(message, options = {})
  super ErrorMessage.build(@base, @attribute, message, options)
end

#to_aObject



33
34
35
# File 'lib/active_model/better_errors/error_message_set.rb', line 33

def to_a
  dup
end