Class: Logux::ChannelController

Inherits:
BaseController show all
Defined in:
lib/logux/channel_controller.rb

Instance Attribute Summary

Attributes inherited from BaseController

#action, #meta

Instance Method Summary collapse

Methods inherited from BaseController

#initialize, #node_id, #respond, unverify_authorized!, #user_id, verify_authorized!

Constructor Details

This class inherits a constructor from Logux::BaseController

Instance Method Details

#initial_dataObject



9
10
11
# File 'lib/logux/channel_controller.rb', line 9

def initial_data
  []
end

#initial_metaObject



13
14
15
# File 'lib/logux/channel_controller.rb', line 13

def initial_meta
  { clients: [meta.client_id] }
end

#since_timeObject



17
18
19
20
21
22
# File 'lib/logux/channel_controller.rb', line 17

def since_time
  @since_time ||= begin
    since = action[:since]&.send(:[], :time)
    Time.at(since).to_datetime if since
  end
end

#subscribeObject



5
6
7
# File 'lib/logux/channel_controller.rb', line 5

def subscribe
  Logux.add_batch(initial_data.map { |d| [d, initial_meta] })
end