Module: CSSPush::PushHelper

Defined in:
lib/css_push.rb

Instance Method Summary collapse

Instance Method Details

#pushify(options = {}) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/css_push.rb', line 13

def pushify(options = {})

  hosts = Juggernaut::CONFIG[:hosts].select {|h| !h[:environment] or h[:environment] == ENV['RAILS_ENV'].to_sym }
  random_host = hosts[rand(hosts.length)]
  options = {
    :host                 => (random_host[:public_host] || random_host[:host]),
    :port                 => (random_host[:public_port] || random_host[:port]),
    :width                => '0px',
    :height               => '0px',
    :session_id           => request.session_options[:id],
    :swf_address          => "/css_push/juggernaut.swf",
    :ei_swf_address       => "/css_push/expressinstall.swf",
    :flash_version        => 8,
    :flash_color          => "#fff",
    :swf_name             => "juggernaut_flash",
    :bridge_name          => "juggernaut",
    :debug                => false,
    :reconnect_attempts   => 3,
    :reconnect_intervals  => 3
  }.merge(options)
  <<-HTML
    #{ javascript_include_tag :css_push }
    #{ javascript_tag "new Juggernaut(#{options.to_json});" }
  HTML
end