Class: Upkeep::Delivery::TurboStreams::Envelope

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#stream_nameObject (readonly)

Returns the value of attribute stream_name

Returns:

  • (Object)

    the current value of stream_name



53
54
55
# File 'lib/upkeep/delivery/turbo_streams.rb', line 53

def stream_name
  @stream_name
end

#streamsObject (readonly)

Returns the value of attribute streams

Returns:

  • (Object)

    the current value of streams



53
54
55
# File 'lib/upkeep/delivery/turbo_streams.rb', line 53

def streams
  @streams
end

#subscriber_idObject (readonly)

Returns the value of attribute subscriber_id

Returns:

  • (Object)

    the current value of subscriber_id



53
54
55
# File 'lib/upkeep/delivery/turbo_streams.rb', line 53

def subscriber_id
  @subscriber_id
end

Class Method Details

.shared(stream_name, streams) ⇒ Object



58
59
60
# File 'lib/upkeep/delivery/turbo_streams.rb', line 58

def self.shared(stream_name, streams)
  new("shared:#{stream_name}", streams, stream_name)
end

.subscriber(subscriber_id, streams) ⇒ Object



54
55
56
# File 'lib/upkeep/delivery/turbo_streams.rb', line 54

def self.subscriber(subscriber_id, streams)
  new(subscriber_id, streams, nil)
end

Instance Method Details

#bodyObject



62
63
64
# File 'lib/upkeep/delivery/turbo_streams.rb', line 62

def body
  streams.map(&:to_html).join("\n")
end

#reportObject



66
67
68
69
70
71
# File 'lib/upkeep/delivery/turbo_streams.rb', line 66

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