Module: Crystalball::Rails::MapGenerator::ActionViewStrategy::Patch
- Defined in:
- lib/crystalball/rails/map_generator/action_view_strategy/patch.rb
Overview
Module to add new patched ‘compile!` method to ActionView::Template
Class Method Summary collapse
-
.apply! ⇒ Object
Patches ‘ActionView::Template#compile!`.
-
.revert! ⇒ Object
Reverts original behavior of ‘ActionView::Template#compile!`.
Instance Method Summary collapse
-
#cb_patched_compile!(*args) ⇒ Object
Will replace original ‘ActionView::Template#compile!`.
Class Method Details
.apply! ⇒ Object
Patches ‘ActionView::Template#compile!`. Renames original `compile!` to `cb_original_compile!` and replaces it with custom one
14 15 16 17 18 19 20 21 |
# File 'lib/crystalball/rails/map_generator/action_view_strategy/patch.rb', line 14 def apply! ::ActionView::Template.class_eval do include Patch alias_method :cb_original_compile!, :compile! alias_method :compile!, :cb_patched_compile! end end |
.revert! ⇒ Object
Reverts original behavior of ‘ActionView::Template#compile!`
24 25 26 27 28 29 |
# File 'lib/crystalball/rails/map_generator/action_view_strategy/patch.rb', line 24 def revert! ::ActionView::Template.class_eval do alias_method :compile!, :cb_original_compile! # rubocop:disable Lint/DuplicateMethods undef_method :cb_patched_compile! end end |
Instance Method Details
#cb_patched_compile!(*args) ⇒ Object
Will replace original ‘ActionView::Template#compile!`. Pushes path of a view to `ActionViewStrategy.views` and calls original `compile!`
34 35 36 37 |
# File 'lib/crystalball/rails/map_generator/action_view_strategy/patch.rb', line 34 def cb_patched_compile!(*args) ActionViewStrategy.views.push identifier cb_original_compile!(*args) end |