Module: Juggernaut::Rails::RenderExtension::InstanceMethods
- Defined in:
- lib/juggernaut/rails/render_extension.rb
Instance Method Summary collapse
- #juggernaut_needs(options, *args) ⇒ Object
- #render_for_juggernaut(data, options = {}) ⇒ Object
- #render_juggernaut(*args) ⇒ Object
-
#render_with_juggernaut(options = nil, extra_options = {}, &block) ⇒ Object
We can’t protect these as ActionMailer complains.
Instance Method Details
#juggernaut_needs(options, *args) ⇒ Object
70 71 72 73 74 |
# File 'lib/juggernaut/rails/render_extension.rb', line 70 def juggernaut_needs(, *args) args.each do |a| raise "You must specify #{a}" unless [a] end end |
#render_for_juggernaut(data, options = {}) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/juggernaut/rails/render_extension.rb', line 35 def render_for_juggernaut(data, = {}) if ! or !.is_a?(Hash) return Juggernaut.send_to_all(data) end case [:type] when :send_to_all Juggernaut.send_to_all(data) when :send_to_channels juggernaut_needs , :channels Juggernaut.send_to_channels(data, [:channels]) when :send_to_channel juggernaut_needs , :channel Juggernaut.send_to_channel(data, [:channel]) when :send_to_client juggernaut_needs , :client_id Juggernaut.send_to_client(data, [:client_id]) when :send_to_clients juggernaut_needs , :client_ids Juggernaut.send_to_clients(data, [:client_ids]) when :send_to_client_on_channel juggernaut_needs , :client_id, :channel Juggernaut.send_to_clients_on_channel(data, [:client_id], [:channel]) when :send_to_clients_on_channel juggernaut_needs , :client_ids, :channel Juggernaut.send_to_clients_on_channel(data, [:client_ids], [:channel]) when :send_to_client_on_channels juggernaut_needs , :client_ids, :channels Juggernaut.send_to_clients_on_channel(data, [:client_id], [:channels]) when :send_to_clients_on_channels juggernaut_needs , :client_ids, :channels Juggernaut.send_to_clients_on_channel(data, [:client_ids], [:channels]) end end |
#render_juggernaut(*args) ⇒ Object
30 31 32 33 |
# File 'lib/juggernaut/rails/render_extension.rb', line 30 def render_juggernaut(*args) = args.last.is_a?(Hash) ? args.pop : {} render_for_juggernaut(render_to_string(*args), ) end |
#render_with_juggernaut(options = nil, extra_options = {}, &block) ⇒ Object
We can’t protect these as ActionMailer complains
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/juggernaut/rails/render_extension.rb', line 10 def render_with_juggernaut( = nil, = {}, &block) if == :juggernaut or (.is_a?(Hash) and [:juggernaut]) begin if @template.respond_to?(:_evaluate_assigns_and_ivars, true) @template.send(:_evaluate_assigns_and_ivars) else @template.send(:evaluate_assigns) end generator = ActionView::Helpers::PrototypeHelper::JavaScriptGenerator.new(@template, &block) render_for_juggernaut(generator.to_s, .is_a?(Hash) ? [:juggernaut] : nil) ensure erase_render_results reset_variables_added_to_assigns end else render_without_juggernaut(, , &block) end end |