Sha256: fa6fbc60739a751a7c57f4ea5617e0ebcddf95adf2041cc69abebf83eef84f4e
Contents?: true
Size: 1.65 KB
Versions: 1
Compression:
Stored size: 1.65 KB
Contents
require "socrates/adapters/stubs" module Socrates module Adapters module Adapter def client_id_from(_context: nil, _user: nil) raise NotImplementedError end def channel_from(_context: nil, _user: nil) raise NotImplementedError end def queue_message(session, message, send_now: false) raise ArgumentError, "session is required" unless session.present? raise ArgumentError, "session.channel is required" unless session.channel.present? session.messages[session.channel] << message flush_session(session, channel: session.channel) if send_now end def queue_direct_message(session, message, recipient) raise ArgumentError, "recipient is required" unless recipient.present? raise ArgumentError, "recipient.if is required" unless recipient.id.present? dm_channel = channel_from(user: recipient) session.messages[dm_channel] << message end def flush_session(session, channel: nil) session.messages.select { |c, _| channel.nil? || channel == c }.each do |c, messages| send_message(c, messages.join("\n\n")) messages.clear end end def send_message(_channel, _message) raise NotImplementedError end def user_from(_context:) raise NotImplementedError end def users_list(*) raise NotImplementedError end def lookup_user(_email:) raise NotImplementedError end def lookup_email(*) raise NotImplementedError end def users_channel(_user) raise NotImplementedError end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
socrates-0.1.17 | lib/socrates/adapters/adapter.rb |