Class: Slanger::Api::Event

Inherits:
Struct
  • Object
show all
Defined in:
lib/slanger/api/event.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#dataObject

Returns the value of attribute data

Returns:

  • (Object)

    the current value of data



5
6
7
# File 'lib/slanger/api/event.rb', line 5

def data
  @data
end

#nameObject

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



5
6
7
# File 'lib/slanger/api/event.rb', line 5

def name
  @name
end

#socket_idObject

Returns the value of attribute socket_id

Returns:

  • (Object)

    the current value of socket_id



5
6
7
# File 'lib/slanger/api/event.rb', line 5

def socket_id
  @socket_id
end

Instance Method Details

#payload(channel_id) ⇒ Object



6
7
8
9
10
11
12
13
# File 'lib/slanger/api/event.rb', line 6

def payload(channel_id)
  Oj.dump({
    event: name,
    data: data,
    channel: channel_id,
    socket_id: socket_id,
  }.select { |_, v| v }, mode: :compat)
end