Sha256: ca4918bc4d9fc3d769c4ffb0363698e7c6e902b4e0ed167adfa553ea72658e7e

Contents?: true

Size: 418 Bytes

Versions: 4

Compression:

Stored size: 418 Bytes

Contents

require 'wechat/api/client'

#
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

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
wechat-api-0.4.3 lib/wechat/api.rb
wechat-api-0.4.2 lib/wechat/api.rb
wechat-api-0.4.1 lib/wechat/api.rb
wechat-api-0.4.0 lib/wechat/api.rb