Last active
December 14, 2015 19:38
-
-
Save 0xradical/5137821 to your computer and use it in GitHub Desktop.
POC - wicked_pdf and remotipart without nasty alias_method_chain
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # wicked pdf | |
| module WickedPdfHelper | |
| def render(options = nil, *args, &block) | |
| if options.is_a?(Hash) && options.has_key?(:pdf) | |
| puts 'do pdf stuff' | |
| end | |
| super | |
| end | |
| end | |
| # remotipart | |
| module RemotipartHelper | |
| def render(*args) | |
| super | |
| puts 'do remotipart stuff' | |
| end | |
| end | |
| class RenderClass | |
| def render(*args) | |
| puts 'main method called' | |
| end | |
| end | |
| class SomeClass < RenderClass | |
| include RemotipartHelper | |
| include WickedPdfHelper | |
| end | |
| SomeClass.new.render(:pdf => true) | |
| # => | |
| # do pdf stuff | |
| # main method called | |
| # do remotipart stuff | |
| class AnotherClass < RenderClass | |
| include WickedPdfHelper | |
| include RemotipartHelper | |
| end | |
| AnotherClass.new.render(:pdf => true) | |
| # => | |
| # do pdf stuff | |
| # main method called | |
| # do remotipart stuff |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment