Sha256: edaed523631e56307bd74ce77adb89c642f89c3cddb0307e048bf2c96df43d82

Contents?: true

Size: 813 Bytes

Versions: 1

Compression:

Stored size: 813 Bytes

Contents

module Rack
  class InAppPurchase
    if ENV['DATABASE_URL']
      DB = Sequel.connect(ENV['DATABASE_URL'])
      Sequel::Migrator.run(DB, ::File.join(::File.dirname(__FILE__), "../migrations"), table: 'in_app_purchase_schema_info')
    end
    
    Sequel::Migrator.run(DB, ::File.join(::File.dirname(__FILE__), "../migrations"))

    class Receipt < Sequel::Model
      plugin :json_serializer, naked: true, except: :id 
      plugin :validation_helpers
      plugin :timestamps, force: true
      
      self.dataset = :in_app_purchase_receipts
      self.strict_param_setting = false
      self.raise_on_save_failure = false

      def validate
        super
      
        validates_presence [:product_id, :transaction_id, :purchase_date]
        validates_unique :transaction_id
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rack-in-app-purchase-0.0.2 ./lib/rack/in-app-purchase/models/receipt.rb