Module: FayePlugin::InstanceMethods

Defined in:
lib/faye-plugin.rb

Instance Method Summary collapse

Instance Method Details

#broadcast(channel, &block) ⇒ Object



17
18
19
20
21
# File 'lib/faye-plugin.rb', line 17

def broadcast(channel, &block)
  message = {:channel => channel, :data => capture(&block), :ext => {:auth_token => FAYE_TOKEN}}
  uri = URI.parse("http://#{Rails.configuration.faye_host}:#{Rails.configuration.faye_port}/faye")
  Net::HTTP.post_form(uri, :message => message.to_json)
end

#faye_watcher(object, attribute) ⇒ Object



13
14
15
# File 'lib/faye-plugin.rb', line 13

def faye_watcher(object, attribute)
  (:div, "#{object[attribute.to_sym]}", {:id => "#{object.class.name.downcase}_#{object.id}_#{attribute}"})
end