Class: RenderSync::PartialCreator
- Inherits:
-
Object
- Object
- RenderSync::PartialCreator
- Defined in:
- lib/render_sync/partial_creator.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#context ⇒ Object
Returns the value of attribute context.
-
#name ⇒ Object
Returns the value of attribute name.
-
#partial ⇒ Object
Returns the value of attribute partial.
-
#resource ⇒ Object
Returns the value of attribute resource.
Instance Method Summary collapse
- #auth_token ⇒ Object
- #channel ⇒ Object
-
#initialize(name, resource, scopes, context) ⇒ PartialCreator
constructor
A new instance of PartialCreator.
- #message ⇒ Object
- #selector ⇒ Object
- #sync_new ⇒ Object
Constructor Details
#initialize(name, resource, scopes, context) ⇒ PartialCreator
Returns a new instance of PartialCreator.
5 6 7 8 9 10 |
# File 'lib/render_sync/partial_creator.rb', line 5 def initialize(name, resource, scopes, context) self.name = name self.resource = Resource.new(resource, scopes) self.context = context self.partial = Partial.new(name, self.resource.model, scopes, context) end |
Instance Attribute Details
#context ⇒ Object
Returns the value of attribute context.
3 4 5 |
# File 'lib/render_sync/partial_creator.rb', line 3 def context @context end |
#name ⇒ Object
Returns the value of attribute name.
3 4 5 |
# File 'lib/render_sync/partial_creator.rb', line 3 def name @name end |
#partial ⇒ Object
Returns the value of attribute partial.
3 4 5 |
# File 'lib/render_sync/partial_creator.rb', line 3 def partial @partial end |
#resource ⇒ Object
Returns the value of attribute resource.
3 4 5 |
# File 'lib/render_sync/partial_creator.rb', line 3 def resource @resource end |
Instance Method Details
#auth_token ⇒ Object
12 13 14 |
# File 'lib/render_sync/partial_creator.rb', line 12 def auth_token @auth_token ||= Channel.new("#{polymorphic_path}-_#{name}").to_s end |
#channel ⇒ Object
16 17 18 |
# File 'lib/render_sync/partial_creator.rb', line 16 def channel @channel ||= auth_token end |
#message ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/render_sync/partial_creator.rb', line 28 def RenderSync.client.(channel, html: partial.render_to_string, 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 |
#selector ⇒ Object
20 21 22 |
# File 'lib/render_sync/partial_creator.rb', line 20 def selector "#{channel}" end |
#sync_new ⇒ Object
24 25 26 |
# File 'lib/render_sync/partial_creator.rb', line 24 def sync_new .publish end |