lib/doorkeeper/models/expirable.rb in doorkeeper-0.4.2 vs lib/doorkeeper/models/expirable.rb in doorkeeper-0.5.0.rc1
- old
+ new
@@ -3,15 +3,17 @@
module Expirable
def expired?
expires_in && Time.now > expired_time
end
- def time_left
- expired? ? 0 : expired_time - Time.now
- end
-
def expired_time
created_at + expires_in.seconds
+ end
+
+ def expires_in_seconds
+ 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