Sha256: c0f067e0f015d677afc0535c9264aad02948c8c4379fd2a7c0f3618ad4194a89

Contents?: true

Size: 517 Bytes

Versions: 4

Compression:

Stored size: 517 Bytes

Contents

# frozen_string_literal: true

require_relative 'basic_model'

module Redd
  module Models
    # Models access_token and related keys.
    class Access < BasicModel
      def expired?(grace_period = 60)
        return false unless @attributes[:expires_in]
        Time.now > @created_at + (@attributes[:expires_in] - grace_period)
      end

      def permanent?
        !@attributes[:refresh_token].nil?
      end

      private

      def after_initialize
        @created_at = Time.now
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
redd-0.8.5 lib/redd/models/access.rb
redd-0.8.4 lib/redd/models/access.rb
redd-0.8.3 lib/redd/models/access.rb
redd-0.8.2 lib/redd/models/access.rb