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



107
108
109
# File 'lib/upkeep/delivery/turbo_streams.rb', line 107

def streams
  @streams
end

Instance Method Details

#envelope_for(subscriber_id) ⇒ Object



114
115
116
# File 'lib/upkeep/delivery/turbo_streams.rb', line 114

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

#envelopesObject



108
109
110
111
112
# File 'lib/upkeep/delivery/turbo_streams.rb', line 108

def envelopes
  return [] if streams.empty?

  shared_envelopes + subscriber_envelopes
end

#reportObject



118
119
120
121
122
123
# File 'lib/upkeep/delivery/turbo_streams.rb', line 118

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