Guest User

Untitled

a guest
Jan 23rd, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.43 KB | None | 0 0
  1. def define_model_callbacks(*callbacks)
  2. options = callbacks.extract_options!
  3. options = {
  4. :terminator => "result == false",
  5. :scope => [:kind, :name],
  6. :only => [:before, :around, :after]
  7. }.merge(options)
  8.  
  9. types = Array.wrap(options.delete(:only))
  10.  
  11. callbacks.each do |callback|
  12. define_callbacks(callback, options)
  13.  
  14. types.each do |type|
  15. send("_define_#{type}_model_callback", self, callback)
  16. end
  17. end
  18. end
Add Comment
Please, Sign In to add comment