Class: Upkeep::Delivery::TurboStreams::Batch

Inherits:
Data
  • Object
show all
Defined in:
lib/upkeep/delivery/turbo_streams.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#streamsObject (readonly)

Returns the value of attribute streams

Returns:

  • (Object)

    the current value of streams



74
75
76
# File 'lib/upkeep/delivery/turbo_streams.rb', line 74

def streams
  @streams
end

Instance Method Details

#envelope_for(subscriber_id) ⇒ Object



84
85
86
# File 'lib/upkeep/delivery/turbo_streams.rb', line 84

def envelope_for(subscriber_id)
  Envelope.subscriber(subscriber_id, streams.select { |stream| stream.for_subscriber?(subscriber_id) })
end

#envelopesObject



75
76
77
78
79
80
81
82
# File 'lib/upkeep/delivery/turbo_streams.rb', line 75

def envelopes
  return [] if streams.empty?

  direct_subscriber_id = single_direct_subscriber_id
  return [Envelope.subscriber(direct_subscriber_id, streams)] if direct_subscriber_id

  shared_envelopes + subscriber_envelopes
end

#reportObject



88
89
90
91
92
93
# File 'lib/upkeep/delivery/turbo_streams.rb', line 88

def report
  {
    streams: streams.map(&:report),
    envelopes: envelopes.map(&:report)
  }
end