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



76
77
78
# File 'lib/upkeep/delivery/turbo_streams.rb', line 76

def streams
  @streams
end

Instance Method Details

#envelope_for(subscriber_id) ⇒ Object



86
87
88
# File 'lib/upkeep/delivery/turbo_streams.rb', line 86

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

#envelopesObject



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

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



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

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