Skip to content

Instantly share code, notes, and snippets.

@aaronlifton
Created May 2, 2017 18:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aaronlifton/4c7f1bfe6cba5358b571e74ed968ecc3 to your computer and use it in GitHub Desktop.
Save aaronlifton/4c7f1bfe6cba5358b571e74ed968ecc3 to your computer and use it in GitHub Desktop.
active support callbacks example
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
@aaronlifton
Copy link
Author

[106] pry(main)> z.derp

1

2

=> nil

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment