Class: Interfacets::Client::Channels::Timer

Inherits:
Object
  • Object
show all
Includes:
Base
Defined in:
lib/interfacets/client/channels/timer.rb

Defined Under Namespace

Classes: Builder

Instance Attribute Summary

Attributes included from Base

#id

Instance Method Summary collapse

Methods included from Base

#initialize, #type

Methods included from ActiveSupport::Concern

#append_features, #class_methods, extended, #included, #prepend_features, #prepended

Instance Method Details

#builder(stream = "defualt") ⇒ Object



35
36
37
# File 'lib/interfacets/client/channels/timer.rb', line 35

def builder(stream = "defualt")
  @builder
end

#handle(event:, entity:) ⇒ Object



39
40
41
42
43
# File 'lib/interfacets/client/channels/timer.rb', line 39

def handle(event:, entity:, **)
  callback_id = event.dig("payload", "id")
  entity.instance_exec(&builder.callbacks.fetch(callback_id))
  builder.callbacks.delete(callback_id)
end

#prepare(entity) ⇒ Object



31
32
33
# File 'lib/interfacets/client/channels/timer.rb', line 31

def prepare(entity)
  @builder ||= Builder.new
end

#result ⇒ Object



45
46
47
# File 'lib/interfacets/client/channels/timer.rb', line 45

def result
  { streams: { default: @builder.flush_event } }
end