class Slack::RPC::Command
## Slack::RPC::Command
A class that represents Slack-RPC style command
Public Class Methods
new(connection, command, sub_commands)
click to toggle source
### Slack::RPC::Commnad.new(conn, command, sub_commands) Creates a new instance of `Slack::RPC::Command` class
# File lib/slack/rpc/command.rb, line 12 def initialize(connection, command, sub_commands) @connection = connection @command = command @sub_commands = sub_commands end
Public Instance Methods
call(sub_command, params, &block)
click to toggle source
### Slack::RPC::Command.invoke_command Invokes Slack
RPC-Style command
# File lib/slack/rpc/command.rb, line 21 def call(sub_command, params, &block) @connection.call(@command, sub_command, params, &block) end
method_missing(name, *args, &block)
click to toggle source
### Slack::RPC::Command.method_missing
(name, *args, &block) Invoked by Ruby when obj is sent a message it cannot handle.
Calls superclass method
# File lib/slack/rpc/command.rb, line 35 def method_missing(name, *args, &block) if @sub_commands.include?(name.to_s) then params = (args.length == 1 && args[0].class == Hash) ? args[0] : {} call(name.to_s, params, &block) else super end end
respond_to?(name)
click to toggle source
### Slack::RPC::Command.respond_to?(name)
Returns true if obj responds to the given method.
Calls superclass method
# File lib/slack/rpc/command.rb, line 28 def respond_to?(name) @sub_commands.include?(name) || super end