Sha256: abbecd6254c8621862ab4fd6430703338c45d592c089bce3dc44717f100b6bc8

Contents?: true

Size: 468 Bytes

Versions: 2

Compression:

Stored size: 468 Bytes

Contents

class MemoryAdapter
  CLIENT_ID = "MEMORY"

  attr_reader :history, :dms

  def initialize
    @history = []
    @dms     = {}
  end

  def client_id_from_context(_context)
    CLIENT_ID
  end

  def send_message(message, *)
    @history << message
  end

  def send_direct_message(message, user, *)
    user = user.id if user.respond_to?(:id)

    @dms[user] = [] unless @dms.key?(user)
    @dms[user] << message
  end

  def last_message
    @history.last
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
socrates-0.1.1 lib/socrates/adapters/memory_adapter.rb
socrates-0.1.0 lib/socrates/adapters/memory_adapter.rb