Class: MailForm::Errors

Inherits:
Hash
  • Object
show all
Defined in:
lib/mail_form/errors.rb

Instance Method Summary collapse

Constructor Details

#initialize(base, *args) ⇒ Errors

Returns a new instance of Errors.



27
28
29
30
# File 'lib/mail_form/errors.rb', line 27

def initialize(base, *args)
  @base = base
  super(*args)
end

Instance Method Details

#full_messagesObject



44
45
46
47
48
49
50
# File 'lib/mail_form/errors.rb', line 44

def full_messages
  map do |attribute, message|
    next if message.nil?
    attribute = attribute.to_sym
    "#{@base.class.human_attribute_name(attribute)} #{generate_message_for(attribute, message)}"
  end.compact.reverse
end

#on(attribute) ⇒ Object Also known as: []



36
37
38
39
40
41
# File 'lib/mail_form/errors.rb', line 36

def on(attribute)
  attribute = attribute.to_sym
  return nil unless get(attribute)

  generate_message_for(attribute, get(attribute))
end