Class: AuctionFunCore::Repos::AuctionContext::AuctionRepository

Inherits:
Object
  • Object
show all
Defined in:
lib/auction_fun_core/repos/auction_context/auction_repository.rb

Overview

SQL repository for auctions.

Instance Method Summary collapse

Instance Method Details

#allArray<ROM::Struct::Auction>, []

Returns all auctions in the database.

Returns:

  • (Array<ROM::Struct::Auction>, [])


15
16
17
# File 'lib/auction_fun_core/repos/auction_context/auction_repository.rb', line 15

def all
  auctions.to_a
end

#by_id(id) ⇒ ROM::Struct::Auction?

Search auction in database by primary key.

Parameters:

  • id (Integer)

    Auction ID

Returns:

  • (ROM::Struct::Auction, nil)


28
29
30
# File 'lib/auction_fun_core/repos/auction_context/auction_repository.rb', line 28

def by_id(id)
  auctions.by_pk(id).one
end

#by_id!(id) ⇒ ROM::Struct::Auction

Search auction in database by primary key.

Parameters:

  • id (Integer)

    Auction ID

Returns:

  • (ROM::Struct::Auction)

Raises:

  • (ROM::TupleCountMismatchError)

    if not found on database



36
37
38
# File 'lib/auction_fun_core/repos/auction_context/auction_repository.rb', line 36

def by_id!(id)
  auctions.by_pk(id).one!
end

#countInteger

Returns the total number of auctions in database.

Returns:

  • (Integer)


21
22
23
# File 'lib/auction_fun_core/repos/auction_context/auction_repository.rb', line 21

def count
  auctions.count
end