Sha256: ab3ebcd1bd25218ee7141d20b06ff4edfae5b8fd411416a8a6b9757a5852ed84
Contents?: true
Size: 1.19 KB
Versions: 20
Compression:
Stored size: 1.19 KB
Contents
# coding: utf-8 module BlsmMpWx class VdMpWx < BaseRecord self.table_name='vd_mp_wxes' validates_uniqueness_of :app_id #判断access_token是否过期了 def access_token_expired? return true unless self.access_token return true unless self.access_token_expire DateTime.now.to_time > self.access_token_expire.to_time end #判断js_api_ticket是否过期了 def js_api_ticket_expired? return true unless self.js_api_ticket return true unless self.js_api_ticket_expire DateTime.now.to_time > self.js_api_ticket_expire.to_time end #保存token的有效期 def save_access_token(access_token, expires_in) update_attributes({ access_token: access_token, access_token_expire: Time.at(DateTime.now.to_time.to_i + expires_in.to_i/4) }) end #保存js_api_ticket def save_js_api_ticket(js_api_ticket, expires_in) update_attributes({ js_api_ticket: js_api_ticket, js_api_ticket_expire: Time.at(DateTime.now.to_time.to_i + expires_in.to_i/4) }) end end end
Version data entries
20 entries across 20 versions & 1 rubygems