class Slack::RealTime::Stores::Store

Stores everything.

Public Class Methods

new(attrs) click to toggle source
# File lib/slack/real_time/stores/store.rb, line 14
def initialize(attrs)
  if attrs.team
    @team_id = attrs.team.id
    @teams = { @team_id => Slack::RealTime::Models::Team.new(attrs.team) }
  else
    @teams = {}
  end

  if attrs.self
    @self_id = attrs.self.id
    @users = { @self_id => Slack::RealTime::Models::User.new(attrs.self) }
  else
    @users = {}
  end

  if attrs.users
    attrs.users.each do |data|
      user = Models::User.new(data)
      @users[data.id] = @users.key?(data.id) ? @users[data.id].merge(user) : user
    end
  end

  @channels = {}
  if attrs.channels
    attrs.channels.each do |data|
      @channels[data.id] = Models::Channel.new(data)
    end
  end

  @bots = {}
  if attrs.bots
    attrs.bots.each do |data|
      @bots[data.id] = Models::Bot.new(data)
    end
  end

  @groups = {}
  if attrs.groups
    attrs.groups.each do |data|
      @groups[data.id] = Models::Group.new(data)
    end
  end

  @ims = {}
  if attrs.ims
    attrs.ims.each do |data|
      @ims[data.id] = Models::Im.new(data)
    end
  end
end

Public Instance Methods

self() click to toggle source
# File lib/slack/real_time/stores/store.rb, line 6
def self
  users[@self_id]
end
team() click to toggle source
# File lib/slack/real_time/stores/store.rb, line 10
def team
  teams[@team_id]
end