Class: Lita::Adapters::Slack::IMMapping Private

Inherits:
Object
  • Object
show all
Defined in:
lib/lita/adapters/slack/im_mapping.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Instance Method Summary collapse

Constructor Details

#initialize(api, ims) ⇒ IMMapping

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of IMMapping.



6
7
8
9
10
11
# File 'lib/lita/adapters/slack/im_mapping.rb', line 6

def initialize(api, ims)
  @api = api
  @mapping = {}

  add_mappings(ims)
end

Instance Method Details

#add_mapping(im) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



13
14
15
# File 'lib/lita/adapters/slack/im_mapping.rb', line 13

def add_mapping(im)
  mapping[im.user_id] = im.id
end

#add_mappings(ims) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



17
18
19
# File 'lib/lita/adapters/slack/im_mapping.rb', line 17

def add_mappings(ims)
  ims.each { |im| add_mapping(im) }
end

#im_for(user_id) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



21
22
23
24
25
26
# File 'lib/lita/adapters/slack/im_mapping.rb', line 21

def im_for(user_id)
  mapping.fetch(user_id) do
    im = api.im_open(user_id)
    mapping[user_id] = im.id
  end
end