Sha256: fba78cfa915b4c87c22e9459565b56b8340181c3a468c6be772e8d5965a94373

Contents?: true

Size: 933 Bytes

Versions: 5

Compression:

Stored size: 933 Bytes

Contents

module StripeLocal
  class Transaction < ActiveRecord::Base
    include ObjectAdapter

    self.primary_key = :id

    time_writer :created, :available_on

    class<<self
      def create object
        super normalize( object )
      end

      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
    end


  #=!=#>>>
  # string   :id
  # integer  :amount
  # datetime :available_on
  # datetime :created
  # integer  :fee
  # integer  :net
  # string   :source_id
  # string   :source_type
  # string   :status
  # string   :description
  #=ยก=#>>>
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
stripe_local-0.1.3 app/models/stripe_local/transaction.rb
stripe_local-0.1.2 app/models/stripe_local/transaction.rb
stripe_local-0.1.1 app/models/stripe_local/transaction.rb
stripe_local-0.1.0 app/models/stripe_local/transaction.rb
stripe_local-0.0.2 app/models/stripe_local/transaction.rb