Class: Slack::RealTime::Store
- Inherits:
-
Object
- Object
- Slack::RealTime::Store
- Defined in:
- lib/slack/real_time/store.rb
Instance Attribute Summary collapse
-
#bots ⇒ Object
Returns the value of attribute bots.
-
#channels ⇒ Object
Returns the value of attribute channels.
-
#groups ⇒ Object
Returns the value of attribute groups.
-
#ims ⇒ Object
Returns the value of attribute ims.
-
#teams ⇒ Object
Returns the value of attribute teams.
-
#users ⇒ Object
Returns the value of attribute users.
Instance Method Summary collapse
-
#initialize(attrs) ⇒ Store
constructor
A new instance of Store.
- #self ⇒ Object
- #team ⇒ Object
Constructor Details
#initialize(attrs) ⇒ Store
Returns a new instance of Store.
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 |
# File 'lib/slack/real_time/store.rb', line 19 def initialize(attrs) if attrs.team @team_id = attrs.team.id @teams = { @team_id => Models::Team.new(attrs.team) } else @teams = {} end { 'users' => Models::User, 'channels' => Models::Channel, 'bots' => Models::Bot, 'groups' => Models::Group, 'ims' => Models::Im }.each_pair do |key, klass| instance_variable_set "@#{key}", {} attrs[key].each do |data| instance_variable_get("@#{key}").send(:[]=, data.id, klass.new(data)) end if attrs.key?(key) end if attrs.self @self_id = attrs.self.id @users[@self_id].merge!(attrs.self) end end |
Instance Attribute Details
#bots ⇒ Object
Returns the value of attribute bots.
5 6 7 |
# File 'lib/slack/real_time/store.rb', line 5 def bots @bots end |
#channels ⇒ Object
Returns the value of attribute channels.
6 7 8 |
# File 'lib/slack/real_time/store.rb', line 6 def channels @channels end |
#groups ⇒ Object
Returns the value of attribute groups.
7 8 9 |
# File 'lib/slack/real_time/store.rb', line 7 def groups @groups end |
#ims ⇒ Object
Returns the value of attribute ims.
9 10 11 |
# File 'lib/slack/real_time/store.rb', line 9 def ims @ims end |
#teams ⇒ Object
Returns the value of attribute teams.
8 9 10 |
# File 'lib/slack/real_time/store.rb', line 8 def teams @teams end |
#users ⇒ Object
Returns the value of attribute users.
4 5 6 |
# File 'lib/slack/real_time/store.rb', line 4 def users @users end |
Instance Method Details
#self ⇒ Object
11 12 13 |
# File 'lib/slack/real_time/store.rb', line 11 def self users[@self_id] end |
#team ⇒ Object
15 16 17 |
# File 'lib/slack/real_time/store.rb', line 15 def team teams[@team_id] end |