callback
forked from mosop/callbackCrystal Callback
A Crystal library for defining and invoking callbacks.
Installation
Add this to your application's shard.yml
:
dependencies:
callback:
github: mosop/callback
Usage
require "callback"
class Record
Callback.enable
define_callback_group :save
before_save do
puts "before"
end
around_save do
puts "around"
end
after_save do
puts "after"
end
on_save do
puts "on"
end
def save
run_callbacks_for_save do
puts "yield"
end
end
end
rec = Record.new
rec.save
This prints:
before
around
on
yield
around
after
For more detail, see Wiki
Release Notes
See Releases.
Repository
callback
Owner
Statistic
- 0
- 1
- 0
- 1
- 1
- about 3 years ago
- August 7, 2019
License
MIT License
Links
Synced at
Sun, 24 Nov 2024 08:20:28 GMT
Languages