Sha256: c350f131dcde6784718566b4f44f5dfff6dd0a09cc5db5acc103d6df9e02ad73
Contents?: true
Size: 824 Bytes
Versions: 2
Compression:
Stored size: 824 Bytes
Contents
module RailsChat module ViewHelpers # Publish the given data or block to the client by sending # a Net::HTTP POST request to the Faye server. If a block # or string is passed in, it is evaluated as JavaScript # on the client. Otherwise it will be converted to JSON # for use in a JavaScript callback. def publish_to(channel, data = nil, &block) RailsChat.publish_to(channel, data || capture(&block)) end # Subscribe the client to the given channel. This generates # some JavaScript calling RailsChat.sign with the subscription # options. def subscribe_to(channel) subscription = RailsChat.subscription(:channel => channel) content_tag "script", :type => "text/javascript" do raw("RailsChat.sign(#{subscription.to_json});") end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
rails_chat-0.0.2 | lib/rails_chat/view_helpers.rb |
rails_chat-0.0.1 | lib/rails_chat/view_helpers.rb |