Class ActiveMerchant::Validateable::Errors
In: lib/active_merchant/lib/validateable.rb
Parent: HashWithIndifferentAccess

This hash keeps the errors of the object

Methods

add   add_to_base   count   each_full   full_messages   new   on  

Public Class methods

[Source]

    # File lib/active_merchant/lib/validateable.rb, line 33
33:       def initialize(base)
34:         @base = base
35:       end

Public Instance methods

[Source]

    # File lib/active_merchant/lib/validateable.rb, line 48
48:       def add(field, error)
49:         self[field] ||= []
50:         self[field] << error
51:       end

[Source]

    # File lib/active_merchant/lib/validateable.rb, line 53
53:       def add_to_base(error)
54:         add(:base, error)
55:       end

[Source]

    # File lib/active_merchant/lib/validateable.rb, line 37
37:       def count
38:         size
39:       end

[Source]

    # File lib/active_merchant/lib/validateable.rb, line 57
57:       def each_full
58:         full_messages.each { |msg| yield msg }      
59:       end

[Source]

    # File lib/active_merchant/lib/validateable.rb, line 61
61:       def full_messages
62:         result = []
63: 
64:         self.each do |key, messages| 
65:           if key == 'base'
66:             result << "#{messages.first}"
67:           else
68:             result << "#{key.to_s.humanize} #{messages.first}"
69:           end
70:         end
71: 
72:         result
73:       end

returns a specific fields error message. if more than one error is available we will only return the first. If no error is available we return an empty string

[Source]

    # File lib/active_merchant/lib/validateable.rb, line 44
44:       def on(field)
45:         self[field].to_a.first
46:       end

[Validate]