Module: Chatops::Controller

Extended by:
ActiveSupport::Concern
Defined in:
lib/chatops/controller.rb

Defined Under Namespace

Modules: ClassMethods, TestCaseHelpers Classes: ConfigurationError, TestCase

Instance Method Summary collapse

Instance Method Details

#execute_chatopObject



45
46
47
48
# File 'lib/chatops/controller.rb', line 45

def execute_chatop
  # This needs to exist for route declarations, but we'll be overriding
  # things in #process to make a method the action.
end

#listObject



18
19
20
21
22
23
24
25
26
27
# File 'lib/chatops/controller.rb', line 18

def list
  chatops = self.class.chatops
  chatops.each { |name, hash| hash[:path] = name }
  render :json => {
    namespace: self.class.chatops_namespace,
    help: self.class.chatops_help,
    error_response: self.class.chatops_error_response,
    methods: chatops,
    version: "3" }
end

#process(*args) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/chatops/controller.rb', line 29

def process(*args)
  setup_params!

  if params[:chatop].present?
    params[:action] = params[:chatop]
    args[0] = params[:action]
    unless self.respond_to?(params[:chatop].to_sym)
      raise AbstractController::ActionNotFound
    end
  end

  super(*args)
rescue AbstractController::ActionNotFound
  return jsonrpc_method_not_found
end