Sha256: 7e99af045bcb339ba7121aed4689d495a3b34a93d236b3cfa7d31bbfbb8df8c3

Contents?: true

Size: 632 Bytes

Versions: 3

Compression:

Stored size: 632 Bytes

Contents

module Slack
  module Web
    module Api
      module Mixins
        module Ids
          private

          def id_for(key, name, prefix, list_method, not_found_error)
            return { 'ok' => true, key.to_s => { 'id' => name } } unless name[0] == prefix

            yield.tap do |list|
              list.public_send(list_method).each do |li|
                return Slack::Messages::Message.new('ok' => true, key.to_s => { 'id' => li.id }) if li.name == name[1..-1]
              end
            end

            fail Slack::Web::Api::Errors::SlackError, not_found_error
          end
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
slack-ruby-client-0.10.0 lib/slack/web/api/mixins/ids.id.rb
slack-ruby-client-0.9.1 lib/slack/web/api/mixins/ids.id.rb
slack-ruby-client-0.9.0 lib/slack/web/api/mixins/ids.id.rb