Module: Wechat::Responder

Extended by:
ActiveSupport::Concern
Defined in:
lib/wechat/responder.rb

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#createObject



81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# File 'lib/wechat/responder.rb', line 81

def create
  request = Wechat::Message.from_hash(params[:xml] || post_xml)
  response = self.class.responder_for(request) do |responder, *args|
    responder ||= self.class.responders(:fallback).first

    next if responder.nil?
    next request.reply.text responder[:respond] if (responder[:respond])
    next responder[:proc].call(*args.unshift(request)) if (responder[:proc])
  end

  if response.respond_to? :to_xml
    render xml: response.to_xml
  else
    render :nothing => true, :status => 200, :content_type => 'text/html'
  end
end

#showObject



77
78
79
# File 'lib/wechat/responder.rb', line 77

def show
  render :text => params[:echostr]
end