Created
May 2, 2017 18:41
-
-
Save aaronlifton/4c7f1bfe6cba5358b571e74ed968ecc3 to your computer and use it in GitHub Desktop.
active support callbacks example
This file contains 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
class V | |
include ActiveSupport::Callbacks | |
define_callbacks :derp | |
set_callback :derp, :after, :after_derp | |
attr_accessor :x | |
def derp | |
run_callbacks :derp do | |
@x = 1 | |
puts @x | |
end | |
end | |
def after_derp | |
@x = 2 | |
puts @x | |
end | |
end |
Author
aaronlifton
commented
May 2, 2017
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment