Module: Puller::ViewHelpers

Defined in:
lib/puller/view_helpers.rb

Instance Method Summary collapse

Instance Method Details

#publish_to(channel_event, data = nil, &block) ⇒ Object



3
4
5
# File 'lib/puller/view_helpers.rb', line 3

def publish_to(channel_event, data = nil, &block)
  Puller.publish_to channel_event, data || capture(&block)
end

#subscribe_to(channel_event) ⇒ Object



7
8
9
10
11
12
13
14
15
# File 'lib/puller/view_helpers.rb', line 7

def subscribe_to(channel_event)
  channel, event = Puller.channel_and_event_for(channel_event)

  options = { :channel => channel, :event => event, :apiKey => Pusher.key }

   "script", :type => "text/javascript" do
    raw "Puller.sign(#{options.to_json});"
  end
end