Class: StripeLocal::Balance
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- StripeLocal::Balance
- Includes:
- ObjectAdapter
- Defined in:
- app/models/stripe_local/balance.rb
Class Method Summary collapse
- .available ⇒ Object (also: current)
- .changed ⇒ Object
- .event(update) ⇒ Object
- .pending ⇒ Object
- .previous_available ⇒ Object (also: previous)
- .previous_pending ⇒ Object
Instance Method Summary collapse
- #to_s ⇒ Object (also: #inspect)
Class Method Details
.available ⇒ Object Also known as: current
11 12 13 |
# File 'app/models/stripe_local/balance.rb', line 11 def available @@cache[:current] ||= all.pluck( :available ).last || 0 end |
.changed ⇒ Object
29 30 31 |
# File 'app/models/stripe_local/balance.rb', line 29 def changed @@cache[:changed] ||= ( self.current - self.previous ) end |
.event(update) ⇒ Object
33 34 35 36 37 38 39 |
# File 'app/models/stripe_local/balance.rb', line 33 def event update if ( self.pending == update[:pending] ) && ( self.available == update[:available] ) Balance.last.touch else Balance.create( update ) end end |
.pending ⇒ Object
16 17 18 |
# File 'app/models/stripe_local/balance.rb', line 16 def pending @@cache[:pending] ||= all.pluck( :pending ).last || 0 end |
.previous_available ⇒ Object Also known as: previous
20 21 22 |
# File 'app/models/stripe_local/balance.rb', line 20 def previous_available @@cache[:previous] ||= all.pluck( :available )[-2] || 0 end |
.previous_pending ⇒ Object
25 26 27 |
# File 'app/models/stripe_local/balance.rb', line 25 def previous_pending @@cache[:previous_pending] ||= all.pluck( :pending )[-2] || 0 end |