lib/wechat/api.rb in wechat-api-0.3.0 vs lib/wechat/api.rb in wechat-api-0.4.0
- old
+ new
@@ -2,7 +2,20 @@
#
module Wechat
#
module Api
+ class Error < StandardError; end
+
+ def self.client(appid = 'origin_id')
+ var = "@_client_#{appid}"
+ if instance_variable_defined?(var)
+ instance_variable_get(var)
+ elsif block_given?
+ c = yield(Client)
+ instance_variable_set var, c
+ else
+ raise Error, :not_initialized
+ end
+ end
end
end