Class: ActiveModel::Pusher::RecordEventRecognizer

Inherits:
Object
  • Object
show all
Defined in:
lib/active_model/pusher/record_event_recognizer.rb

Instance Method Summary collapse

Constructor Details

#initialize(record) ⇒ RecordEventRecognizer

Returns a new instance of RecordEventRecognizer.



4
5
6
# File 'lib/active_model/pusher/record_event_recognizer.rb', line 4

def initialize(record)
  @record = record
end

Instance Method Details

#eventObject



8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/active_model/pusher/record_event_recognizer.rb', line 8

def event
  return nil unless can_be_recognized?

  if created?
    :created
  elsif updated?
    :updated
  elsif destroyed?
    :destroyed
  else
    nil
  end
end