Sha256: 9d69299959e03e4b72dfe0185f4d55cc197167cbae3d633a556408378114663f

Contents?: true

Size: 480 Bytes

Versions: 6

Compression:

Stored size: 480 Bytes

Contents

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

      def expired_time
        created_at + expires_in.seconds
      end

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

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
doorkeeper-1.4.2 lib/doorkeeper/models/expirable.rb
doorkeeper-1.4.1 lib/doorkeeper/models/expirable.rb
doorkeeper-1.4.0 lib/doorkeeper/models/expirable.rb
doorkeeper-1.3.1 lib/doorkeeper/models/expirable.rb
doorkeeper-1.3.0 lib/doorkeeper/models/expirable.rb
doorkeeper-1.2.0 lib/doorkeeper/models/expirable.rb