Module: Rails2ViewToggler::PartialTogglingSupport
- Defined in:
- lib/rails2_view_toggler.rb
Class Method Summary collapse
Instance Method Summary collapse
- #partial_name_when_toggle_on(original_name) ⇒ Object
- #render_with_partials_toggling(options = {}, local_assigns = {}, &block) ⇒ Object
Class Method Details
.included(base) ⇒ Object
34 35 36 |
# File 'lib/rails2_view_toggler.rb', line 34 def self.included(base) base.alias_method_chain :render, :partials_toggling end |
Instance Method Details
#partial_name_when_toggle_on(original_name) ⇒ Object
20 21 22 23 24 |
# File 'lib/rails2_view_toggler.rb', line 20 def partial_name_when_toggle_on(original_name) paths = original_name.split('/') paths[-1] = "new_#{paths[-1]}" paths.join('/') end |
#render_with_partials_toggling(options = {}, local_assigns = {}, &block) ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/rails2_view_toggler.rb', line 26 def render_with_partials_toggling( = {}, local_assigns = {}, &block) if Hash === && [:partial] && toggle_is_on = Rails2ViewToggler.mapping[[:partial]] [:partial] = partial_name_when_toggle_on([:partial]) if toggle_is_on end render_without_partials_toggling(, local_assigns, &block) end |