Class: ActiveModel::Pusher

Inherits:
Object
  • Object
show all
Defined in:
lib/active_model/pusher.rb,
lib/active_model/pusher/events.rb,
lib/active_model/pusher/version.rb,
lib/active_model/pusher/record_channel.rb,
lib/active_model/pusher/record_serializer.rb,
lib/active_model/pusher/record_event_recognizer.rb

Defined Under Namespace

Classes: Events, RecordChannel, RecordEventRecognizer, RecordSerializer

Constant Summary collapse

VERSION =
"0.0.1"

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(record) ⇒ Pusher

Returns a new instance of Pusher.



13
14
15
# File 'lib/active_model/pusher.rb', line 13

def initialize(record)
  @record = record
end

Class Method Details

.events(*events) ⇒ Object



8
9
10
# File 'lib/active_model/pusher.rb', line 8

def events(*events)
  self._events = events
end

Instance Method Details

#push!(event_or_params = nil, params = {}) ⇒ Object



17
18
19
20
21
22
23
24
25
# File 'lib/active_model/pusher.rb', line 17

def push!(event_or_params = nil, params = {})
  event, params = parse_push_params(event_or_params, params)

  event ||= RecordEventRecognizer.new(record).event

  events.validate! event

  ::Pusher.trigger channel(event), event(event), data, params
end