Class: Slack::RealTime::Stores::Store
- Defined in:
- lib/slack/real_time/stores/store.rb
Overview
Stores everything.
Instance Attribute Summary
Attributes inherited from Base
#bots, #channels, #groups, #ims, #teams, #users
Instance Method Summary collapse
-
#initialize(attrs) ⇒ Store
constructor
A new instance of Store.
- #self ⇒ Object
- #team ⇒ Object
Methods inherited from Base
Constructor Details
#initialize(attrs) ⇒ Store
Returns a new instance of Store.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# 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 attrs.users.each do |data| user = Models::User.new(data) @users[data.id] = @users.key?(data.id) ? @users[data.id].merge(user) : user end if attrs.users @channels = {} attrs.channels.each do |data| @channels[data.id] = Models::Channel.new(data) end if attrs.channels @bots = {} attrs.bots.each do |data| @bots[data.id] = Models::Bot.new(data) end if attrs.bots @groups = {} attrs.groups.each do |data| @groups[data.id] = Models::Group.new(data) end if attrs.groups @ims = {} attrs.ims.each do |data| @ims[data.id] = Models::Im.new(data) end if attrs.ims end |
Instance Method Details
#self ⇒ Object
6 7 8 |
# File 'lib/slack/real_time/stores/store.rb', line 6 def self users[@self_id] end |
#team ⇒ Object
10 11 12 |
# File 'lib/slack/real_time/stores/store.rb', line 10 def team teams[@team_id] end |