Skip to content

Instantly share code, notes, and snippets.

@JohnAmican
Created August 30, 2015 16:42
Show Gist options
  • Save JohnAmican/bd8919804779040cd182 to your computer and use it in GitHub Desktop.
Save JohnAmican/bd8919804779040cd182 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