Class: Pakyow::UI::Handler Private

Inherits:
Object
  • Object
show all
Defined in:
lib/pakyow/ui/handler.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ Handler

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Handler.



16
17
18
# File 'lib/pakyow/ui/handler.rb', line 16

def initialize(app)
  @app = app
end

Instance Method Details

#call(args, subscription: nil, result: nil) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/pakyow/ui/handler.rb', line 20

def call(args, subscription: nil, result: nil)
  renderer = Marshal.restore(args[:metadata])[:renderer]
  renderer.presentables[:__ui_transform] = true

  # If an ephemeral caused the update, replace the value for any matching presentables.
  #
  if result.is_a?(Data::Sources::Ephemeral)
    renderer.presentables.each do |key, value|
      if value.is_a?(Data::Proxy) && value.source.is_a?(Data::Sources::Ephemeral) && value.source.type == result.type && value.source.qualifications == result.qualifications
        value.instance_variable_set(:@source, result)
      end
    end
  end

  renderer.perform

  @app.websocket_server.subscription_broadcast(
    Realtime::Channel.new(:transformation, subscription[:id]),
    { id: args[:transformation_id], calls: renderer.presenter }
  )
end