Sha256: 6b835abf604e7f8651266a896981835c838cd9c46b48fe543032058d8bd6dcef

Contents?: true

Size: 701 Bytes

Versions: 2

Compression:

Stored size: 701 Bytes

Contents

# frozen_string_literal: true
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|
                if li.name == name[1..-1]
                  return Slack::Messages::Message.new('ok' => true, key.to_s => { 'id' => li.id })
                end
              end
            end

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
slack-ruby-client-0.14.6 lib/slack/web/api/mixins/ids.id.rb
slack-ruby-client-0.14.5 lib/slack/web/api/mixins/ids.id.rb