Class: SettingsManager::Errors::InvalidError::ComplexErrorArray

Inherits:
Array
  • Object
show all
Defined in:
lib/settings-manager/errors.rb

Instance Method Summary collapse

Instance Method Details

#<<(obj) ⇒ Object



8
9
10
11
12
13
14
# File 'lib/settings-manager/errors.rb', line 8

def <<(obj)
  unless obj.is_a?(String) || obj.is_a?(ActiveModel::Errors)
    raise ArgumentError
  end

  super
end

#messagesObject



16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/settings-manager/errors.rb', line 16

def messages
  messages = []

  self.each do |message|
    if message.is_a?(String)
      messages << message
    elsif message.is_a?(ActiveModel::Errors)
      message.full_messages.each { |m| messages << m }
    end
  end

  messages.uniq
end