Sha256: ef99f0ed6fb64436c8c3289ff359c5c5616d5c5da5afa71b8fbb9d320c1965ac

Contents?: true

Size: 475 Bytes

Versions: 5

Compression:

Stored size: 475 Bytes

Contents

module Doorkeeper
  module Models
    module Expirable
      def expired?
        expires_in && Time.now.utc > expired_time
      end

      def expires_in_seconds
        return nil if expires_in.nil?
        expires = (created_at + expires_in.seconds) - Time.now.utc
        expires_sec = expires.seconds.round(0)
        expires_sec > 0 ? expires_sec : 0
      end

      private

      def expired_time
        created_at + expires_in.seconds
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
doorkeeper-4.2.0 lib/doorkeeper/models/concerns/expirable.rb
doorkeeper-4.1.0 lib/doorkeeper/models/concerns/expirable.rb
doorkeeper-4.0.0 lib/doorkeeper/models/concerns/expirable.rb
doorkeeper-4.0.0.rc4 lib/doorkeeper/models/concerns/expirable.rb
doorkeeper-4.0.0.rc3 lib/doorkeeper/models/concerns/expirable.rb