Skip to content

Instantly share code, notes, and snippets.

@nononoy
Forked from JohnAmican/before_render.rb
Created February 16, 2016 13:39
Show Gist options
  • Select an option

  • Save nononoy/4b9f2474dcd477d5b4a8 to your computer and use it in GitHub Desktop.

Select an option

Save nononoy/4b9f2474dcd477d5b4a8 to your computer and use it in GitHub Desktop.
module BeforeRender
extend ActiveSupport::Concern
included do
define_callbacks :render
end
def render(*args, &block)
run_callbacks(:render) do
super
end
end
module ClassMethods
def before_render(*names, &blk)
_insert_callbacks(names, blk) do |name, options|
set_callback(:render, :before, name, options)
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment