Class: Purchase

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/purchase.rb

Overview

The Purchase model handles purchase related informations for the nearspeak tag.

Class Method Summary (collapse)

Class Method Details

+ (Object) check_purchases(purchase_id)

Check if there are enough purchases available.

Parameters:

  • purchase_id (String)

    The purchase id.



12
13
14
15
16
17
18
19
20
21
22
# File 'app/models/purchase.rb', line 12

def self.check_purchases(purchase_id)
  if PurchasesHelper.validate_purchase_id(purchase_id)
    purchases = Purchase.where('purchase_id = ?', purchase_id)

    unless purchases.nil?
      return purchases.length
    end
  end

  return MAX_TAGS_PER_PURCHASE_ID
end