Class: Ask::Slack::ClientProxy

Inherits:
BasicObject
Defined in:
lib/ask/slack/client.rb

Overview

Proxies method calls to a ::Slack::Web::Client, converting authentication errors into Ask::Auth::InvalidCredential.

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ ClientProxy

Returns a new instance of ClientProxy.



35
36
37
# File 'lib/ask/slack/client.rb', line 35

def initialize(client)
  @client = client
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name) ⇒ Object



39
40
41
42
43
44
45
46
47
# File 'lib/ask/slack/client.rb', line 39

def method_missing(name, ...)
  @client.public_send(name, ...)
rescue ::Slack::Web::Api::Errors::NotAuthed,
       ::Slack::Web::Api::Errors::InvalidAuth,
       ::Slack::Web::Api::Errors::AccountInactive,
       ::Slack::Web::Api::Errors::TokenRevoked,
       ::Slack::Web::Api::Errors::TokenExpired
  ::Kernel.raise ::Ask::Auth::InvalidCredential, :slack_token
end

Instance Method Details

#respond_to_missing?(name, include_private = false) ⇒ Boolean

Returns:

  • (Boolean)


49
50
51
# File 'lib/ask/slack/client.rb', line 49

def respond_to_missing?(name, include_private = false)
  @client.respond_to?(name, include_private) || super
end