j-sm-n / black_thursday

Black Thursday is a system that is able to load, parse, search, and execute business intelligence queries against the data from a typical e-commerece business in Ruby.
0 stars 0 forks source link

Data Access Layer - TransactionRepository #44

Closed jesse-spevack closed 8 years ago

jesse-spevack commented 8 years ago

TransactionRepository

Transactions are billing records for an invoice. An invoice can have multiple transactions, but should have at most one that is successful.

The TransactionRepository is responsible for holding and searching our Transaction instances. It offers the following methods:

all - returns an array of all known Transaction instances find_by_id - returns either nil or an instance of Transaction with a matching ID find_all_by_invoice_id - returns either [] or one or more matches which have a matching invoice ID find_all_by_credit_card_number - returns either [] or one or more matches which have a matching credit card number find_all_by_result - returns either [] or one or more matches which have a matching status The data can be found in data/transactions.csv so the instance is created and used like this:

tr = TransactionRepository.new tr.from_csv("./data/transactions.csv") transaction = tr.find_by_id(6)

=>

https://github.com/turingschool/curriculum/blob/master/source/projects/black_thursday/iteration_3.markdown#transactionrepository