Class: StripeLocal::Transaction

Inherits:
ActiveRecord::Base
  • Object
show all
Includes:
ObjectAdapter
Defined in:
app/models/stripe_local/transaction.rb

Class Method Summary collapse

Class Method Details

.availableObject



37
38
39
# File 'app/models/stripe_local/transaction.rb', line 37

def available
  where 'available_on > ?', Time.now
end

.create(object) ⇒ Object



13
14
15
# File 'app/models/stripe_local/transaction.rb', line 13

def create object
  super normalize( object )
end

.normalize(attrs) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'app/models/stripe_local/transaction.rb', line 17

def normalize attrs
  attrs.each_with_object({}) do |(k,v),h|
    key = case k.to_sym
    when :source then :source_id
    when :type   then :source_type
    when ->(x){attribute_method? x} then k.to_sym
    else next
    end
    if v.is_a?(Numeric) && v > 1000000000
      h[key] = Time.at( v )
    else
      h[key] = v
    end
  end
end

.pendingObject



33
34
35
# File 'app/models/stripe_local/transaction.rb', line 33

def pending
  where 'available_on < ?', Time.now
end