module Volt::ClassEventable
ClassEventable
behaves like Eventable
, except events can be bound with a class on method. When triggered on an instance, the self in the block will be the instance it was triggered on. This allows classes to easy setup listeners.
Example:
class Post on(:create) do deny if owner? end end
Public Class Methods
included(base)
click to toggle source
# File lib/volt/reactive/class_eventable.rb, line 62 def self.included(base) base.class_attribute :__listeners__ # Include the base eventable so the class can be triggered on base.send :include, Volt::Eventable base.send :extend, ClassMethods base.send :include, InstanceMethods end