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



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

def stream_name
  @stream_name
end

#streamsObject (readonly)

Returns the value of attribute streams

Returns:

  • (Object)

    the current value of streams



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

def streams
  @streams
end

#subscriber_idObject (readonly)

Returns the value of attribute subscriber_id

Returns:

  • (Object)

    the current value of subscriber_id



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

def subscriber_id
  @subscriber_id
end

Class Method Details

.shared(stream_name, streams) ⇒ Object



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

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

.subscriber(subscriber_id, streams) ⇒ Object



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

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

Instance Method Details

#bodyObject



71
72
73
# File 'lib/upkeep/delivery/turbo_streams.rb', line 71

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

#reportObject



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

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