Class: SeeingIsBelieving::EventStream::Handlers::StreamJsonEvents
- Inherits:
-
Object
- Object
- SeeingIsBelieving::EventStream::Handlers::StreamJsonEvents
- Defined in:
- lib/seeing_is_believing/event_stream/handlers/stream_json_events.rb
Instance Attribute Summary collapse
-
#stream ⇒ Object
readonly
Returns the value of attribute stream.
Instance Method Summary collapse
- #call(event) ⇒ Object
-
#initialize(stream) ⇒ StreamJsonEvents
constructor
A new instance of StreamJsonEvents.
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
#stream ⇒ Object (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 |