Class: RenderSync::RefetchPartialCreator

Inherits:
PartialCreator show all
Defined in:
lib/render_sync/refetch_partial_creator.rb

Instance Attribute Summary

Attributes inherited from PartialCreator

#context, #name, #partial, #resource

Instance Method Summary collapse

Methods inherited from PartialCreator

#auth_token, #channel, #selector, #sync_new

Constructor Details

#initialize(name, resource, scoped_resource, context) ⇒ RefetchPartialCreator

Returns a new instance of RefetchPartialCreator.



4
5
6
7
# File 'lib/render_sync/refetch_partial_creator.rb', line 4

def initialize(name, resource, scoped_resource, context)
  super
  self.partial = RefetchPartial.new(name, self.resource.model, nil, context)
end

Instance Method Details

#messageObject



9
10
11
12
13
14
15
16
17
18
19
# File 'lib/render_sync/refetch_partial_creator.rb', line 9

def message
  RenderSync.client.build_message(channel,
    refetch: true,
    resourceId: resource.id,
    authToken: partial.auth_token,
    channelUpdate: partial.channel_for_action(:update),
    channelDestroy: partial.channel_for_action(:destroy),
    selectorStart: partial.selector_start,
    selectorEnd: partial.selector_end
  )
end