Class: SpreeCmCommissioner::WaitingRoomLobbyMetadataFetcher

Inherits:
Object
  • Object
show all
Defined in:
app/services/spree_cm_commissioner/waiting_room_lobby_metadata_fetcher.rb

Overview

Reads the lobby document (waiting_rooms/lobby) — the read-side counterpart to WaitingRoom::PublishLobbyPath. Kept separate from WaitingRoomSystemMetadataFetcher, which owns the unrelated metadata/system document.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(firestore: nil) ⇒ WaitingRoomLobbyMetadataFetcher

Returns a new instance of WaitingRoomLobbyMetadataFetcher.



10
11
12
# File 'app/services/spree_cm_commissioner/waiting_room_lobby_metadata_fetcher.rb', line 10

def initialize(firestore: nil)
  @firestore = firestore if firestore.present?
end

Instance Attribute Details

#document_dataObject (readonly)

Returns the value of attribute document_data.



8
9
10
# File 'app/services/spree_cm_commissioner/waiting_room_lobby_metadata_fetcher.rb', line 8

def document_data
  @document_data
end

Instance Method Details

#available_slotsObject

written by WaitingGuestsCaller#mark_as.



31
32
33
# File 'app/services/spree_cm_commissioner/waiting_room_lobby_metadata_fetcher.rb', line 31

def available_slots
  document_data[:available_slots]
end

#documentObject



35
36
37
# File 'app/services/spree_cm_commissioner/waiting_room_lobby_metadata_fetcher.rb', line 35

def document
  @document ||= firestore.col('waiting_rooms').doc('lobby')
end

#firestoreObject



39
40
41
# File 'app/services/spree_cm_commissioner/waiting_room_lobby_metadata_fetcher.rb', line 39

def firestore
  @firestore ||= Google::Cloud::Firestore.new(project_id: [:project_id], credentials: )
end

#fullObject

written by WaitingGuestsCaller#mark_as.



26
27
28
# File 'app/services/spree_cm_commissioner/waiting_room_lobby_metadata_fetcher.rb', line 26

def full
  document_data[:full]
end

#load_document_dataObject



14
15
16
# File 'app/services/spree_cm_commissioner/waiting_room_lobby_metadata_fetcher.rb', line 14

def load_document_data
  @document_data = document.get.data || {}
end

#service_accountObject



43
44
45
# File 'app/services/spree_cm_commissioner/waiting_room_lobby_metadata_fetcher.rb', line 43

def 
  @service_account ||= Rails.application.credentials.
end

#waiting_guests_records_pathObject

server-owned date partition — see WaitingRoom::PublishLobbyPath.



21
22
23
# File 'app/services/spree_cm_commissioner/waiting_room_lobby_metadata_fetcher.rb', line 21

def waiting_guests_records_path
  document_data[:waiting_guests_records_path]
end