Class: ActiveMerchant::Billing::Rails::Model::Errors
- Inherits:
-
Hash
- Object
- Hash
- ActiveMerchant::Billing::Rails::Model::Errors
- Defined in:
- lib/active_merchant/billing/compatibility.rb
Instance Method Summary collapse
- #[](key) ⇒ Object
- #[]=(key, value) ⇒ Object
- #add(field, error) ⇒ Object
- #add_to_base(error) ⇒ Object
- #each_full ⇒ Object
- #empty? ⇒ Boolean
- #full_messages ⇒ Object
-
#initialize ⇒ Errors
constructor
A new instance of Errors.
- #on(field) ⇒ Object
Constructor Details
#initialize ⇒ Errors
Returns a new instance of Errors.
63 64 65 |
# File 'lib/active_merchant/billing/compatibility.rb', line 63 def initialize super() { |h, k| h[k] = [] } end |
Instance Method Details
#[](key) ⇒ Object
69 70 71 |
# File 'lib/active_merchant/billing/compatibility.rb', line 69 def [](key) super(key.to_s) end |
#[]=(key, value) ⇒ Object
73 74 75 |
# File 'lib/active_merchant/billing/compatibility.rb', line 73 def []=(key, value) super(key.to_s, value) end |
#add(field, error) ⇒ Object
85 86 87 |
# File 'lib/active_merchant/billing/compatibility.rb', line 85 def add(field, error) self[field] << error end |
#add_to_base(error) ⇒ Object
89 90 91 |
# File 'lib/active_merchant/billing/compatibility.rb', line 89 def add_to_base(error) add(:base, error) end |
#each_full ⇒ Object
93 94 95 |
# File 'lib/active_merchant/billing/compatibility.rb', line 93 def each_full .each { |msg| yield msg } end |
#empty? ⇒ Boolean
77 78 79 |
# File 'lib/active_merchant/billing/compatibility.rb', line 77 def empty? all? { |k, v| v&.empty? } end |
#full_messages ⇒ Object
97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/active_merchant/billing/compatibility.rb', line 97 def result = [] self.each do |key, | next unless( && !.empty?) if key == 'base' result << .first.to_s else result << "#{Compatibility.humanize(key)} #{.first}" end end result end |
#on(field) ⇒ Object
81 82 83 |
# File 'lib/active_merchant/billing/compatibility.rb', line 81 def on(field) self[field].to_a.first end |