Sha256: af90d81624d5c3836ed3c859ebe89d45c0cb33e5bfd47654bbf5a3a0be769a5c
Contents?: true
Size: 959 Bytes
Versions: 3
Compression:
Stored size: 959 Bytes
Contents
# frozen_string_literal: true module Micro module Observers module For module ActiveModel module ClassMethods def notify_observers!(events) proc do |object| object.observers.subject_changed! object.observers.send(:broadcast_if_subject_changed, events) end end def notify_observers(*events) notify_observers!(Event::Names.fetch(events)) end def notify_observers_on(*callback_methods) Utils::Arrays.fetch_from_args(callback_methods).each do |callback_method| self.public_send(callback_method, ¬ify_observers!([callback_method])) end end end def self.included(base) base.extend(ClassMethods) base.send(:private_class_method, :notify_observers!) base.send(:include, ::Micro::Observers) end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
u-observers-2.3.0 | lib/micro/observers/for/active_model.rb |
u-observers-2.2.1 | lib/micro/observers/for/active_model.rb |
u-observers-2.2.0 | lib/micro/observers/for/active_model.rb |