Class: ReactiveObservers::Observable::Notification

Inherits:
Object
  • Object
show all
Defined in:
lib/reactive_observers/observable/notification.rb

Instance Method Summary collapse

Constructor Details

#initialize(observed_object, observers, action, options) ⇒ Notification

Returns a new instance of Notification.



8
9
10
11
12
13
# File 'lib/reactive_observers/observable/notification.rb', line 8

def initialize(observed_object, observers, action, options)
  @observed_object = observed_object
  @observers = observers
  @action = action
  @options = options
end

Instance Method Details

#performObject



15
16
17
18
19
20
21
22
# File 'lib/reactive_observers/observable/notification.rb', line 15

def perform
  filter_observers.each do |observer|
    process observer, @observed_object
    if @action == :update && observer.trigger_with_previous_values
      process observer, @observed_object.clone.assign_attributes(@options[:diff])
    end
  end
end