Class: Slack::RealTime::Stores::Store
- Defined in:
- lib/slack/real_time/stores/store.rb
Overview
Full store with initialization logic
Constant Summary collapse
- CONVERSATION_TYPES =
{ public_channels: 'public_channel', private_channels: 'private_channel', ims: 'im', mpims: 'mpim' }.freeze
Constants inherited from Base
Instance Attribute Summary collapse
-
#caches ⇒ Object
readonly
Returns the value of attribute caches.
Instance Method Summary collapse
-
#initialize(attrs, options = {}) ⇒ Store
constructor
A new instance of Store.
- #self ⇒ Object
- #team ⇒ Object
Methods inherited from Base
Constructor Details
#initialize(attrs, options = {}) ⇒ Store
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 |
# File 'lib/slack/real_time/stores/store.rb', line 17 def initialize(attrs, = {}) @teams = {} @users = {} @bots = {} @public_channels = {} @private_channels = {} @ims = {} @mpims = {} if attrs.team @team_id = attrs.team.id @teams[@team_id] = Models::Team.new(attrs.team) end if attrs.self @self_id = attrs.self.id @users[@self_id] = Models::User.new(attrs.self) end @caches = if [:caches].is_a?(Array) || [:caches].nil? caches = [:caches].to_a.map(&:to_sym) unknown_caches = caches - CACHES raise ArgumentError, "Unknown caches: #{unknown_caches.join(', ')}" unless unknown_caches.empty? Set.new(caches).freeze elsif [:caches] == :all Set.new(CACHES).freeze else raise ArgumentError, 'Unexpected value for option `caches`. Expects :all or an array of caches' end end |
Instance Attribute Details
#caches ⇒ Object (readonly)
Returns the value of attribute caches.
15 16 17 |
# File 'lib/slack/real_time/stores/store.rb', line 15 def caches @caches end |
Instance Method Details
#self ⇒ Object
50 51 52 |
# File 'lib/slack/real_time/stores/store.rb', line 50 def self users[@self_id] end |
#team ⇒ Object
54 55 56 |
# File 'lib/slack/real_time/stores/store.rb', line 54 def team teams[@team_id] end |