davydovanton / kan

Simple, functional authorization library and role management for ruby
http://www.kanrb.org
MIT License
232 stars 12 forks source link

Allow to setup notification callback for all abilities #27

Closed davydovanton closed 5 years ago

davydovanton commented 6 years ago

Let's try to create only after_call_callback for broadcasting notifications for any frameworks:

abilities = Kan::Application.new(
  post: Post::Abilities.new(after_call_callback: -> (ability_name, payload) { ... }),
  comment: Comments::Abilities.new
)

abilities['post.read'].call(current_user, post) # => true
abilities['post.delete'].call(current_user, post) # => false
abilities['comment.delete'].call(current_user, post) # => false