Class: SeeingIsBelieving::EventStream::Handlers::StreamJsonEvents

Inherits:
Object
  • Object
show all
Defined in:
lib/seeing_is_believing/event_stream/handlers/stream_json_events.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(stream) ⇒ StreamJsonEvents

Returns a new instance of StreamJsonEvents.



8
9
10
11
12
13
# File 'lib/seeing_is_believing/event_stream/handlers/stream_json_events.rb', line 8

def initialize(stream)
  @flush          = true if stream.respond_to? :flush
  @stream         = stream
  @has_exception  = false
  @exitstatus     = :not_yet_seen
end

Instance Attribute Details

#streamObject (readonly)

Returns the value of attribute stream.



6
7
8
# File 'lib/seeing_is_believing/event_stream/handlers/stream_json_events.rb', line 6

def stream
  @stream
end

Instance Method Details

#call(event) ⇒ Object



15
16
17
18
19
# File 'lib/seeing_is_believing/event_stream/handlers/stream_json_events.rb', line 15

def call(event)
  @stream << JSON.dump(event.as_json)
  @stream << "\n"
  @stream.flush if @flush
end