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.
65 66 67 |
# File 'lib/active_merchant/billing/compatibility.rb', line 65 def initialize super(){|h, k| h[k] = []} end |
Instance Method Details
#[](key) ⇒ Object
71 72 73 |
# File 'lib/active_merchant/billing/compatibility.rb', line 71 def [](key) super(key.to_s) end |
#[]=(key, value) ⇒ Object
75 76 77 |
# File 'lib/active_merchant/billing/compatibility.rb', line 75 def []=(key, value) super(key.to_s, value) end |
#add(field, error) ⇒ Object
87 88 89 |
# File 'lib/active_merchant/billing/compatibility.rb', line 87 def add(field, error) self[field] << error end |
#add_to_base(error) ⇒ Object
91 92 93 |
# File 'lib/active_merchant/billing/compatibility.rb', line 91 def add_to_base(error) add(:base, error) end |
#each_full ⇒ Object
95 96 97 |
# File 'lib/active_merchant/billing/compatibility.rb', line 95 def each_full .each{|msg| yield msg} end |
#empty? ⇒ Boolean
79 80 81 |
# File 'lib/active_merchant/billing/compatibility.rb', line 79 def empty? all?{|k, v| v && v.empty?} end |
#full_messages ⇒ Object
99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/active_merchant/billing/compatibility.rb', line 99 def result = [] self.each do |key, | next unless( && !.empty?) if key == 'base' result << "#{.first}" else result << "#{Compatibility.humanize(key)} #{.first}" end end result end |
#on(field) ⇒ Object
83 84 85 |
# File 'lib/active_merchant/billing/compatibility.rb', line 83 def on(field) self[field].to_a.first end |