Sha256: 94b66341494961c9928d10f7c3b4a2c71abccbaff8dc86169c13957c248e0edc

Contents?: true

Size: 633 Bytes

Versions: 10

Compression:

Stored size: 633 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

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

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
slack-ruby-client-0.14.4 lib/slack/web/api/mixins/ids.id.rb
slack-ruby-client-0.14.3 lib/slack/web/api/mixins/ids.id.rb
slack-ruby-client-0.14.2 lib/slack/web/api/mixins/ids.id.rb
slack-ruby-client-0.14.1 lib/slack/web/api/mixins/ids.id.rb
slack-ruby-client-0.14.0 lib/slack/web/api/mixins/ids.id.rb
slack-ruby-client-0.13.1 lib/slack/web/api/mixins/ids.id.rb
slack-ruby-client-0.13.0 lib/slack/web/api/mixins/ids.id.rb
slack-ruby-client-0.12.0 lib/slack/web/api/mixins/ids.id.rb
slack-ruby-client-0.11.1 lib/slack/web/api/mixins/ids.id.rb
slack-ruby-client-0.11.0 lib/slack/web/api/mixins/ids.id.rb