Sha256: c6872a3119cdfb51c9dab3ad6d34cd4dba56c1c96c8b6850d5eeb72c16367c89

Contents?: true

Size: 675 Bytes

Versions: 1

Compression:

Stored size: 675 Bytes

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

    #保存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

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
blsm-mp-wx-0.1.0 lib/blsm_mp_wx/model/vd_mp_wx.rb