Skip to content

Commit

Permalink
Some JSON implementations like to return dates parsed for you into Da…
Browse files Browse the repository at this point in the history
…teTime objects. Quick hack to workaround this (tests broken, pending a refactor)
  • Loading branch information
courtenay committed Apr 16, 2011
1 parent f1c8a4a commit 2f909bf
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
4 changes: 2 additions & 2 deletions VERSION.yml
@@ -1,5 +1,5 @@
---
:major: 1
:minor: 2
:patch: 3
:minor: 3
:patch: 0
:build:
8 changes: 7 additions & 1 deletion lib/multipass.rb
Expand Up @@ -81,8 +81,14 @@ def decode(data)
options.keys.each do |key|
options[key.to_sym] = unencode_javascript_unicode_escape(options.delete(key))
end

# Force everything coming out of json into a Time object if it isn't already
# with YAJL, it parses dates for us (ugh)
if options.has_key?(:expires) && options[:expires].is_a?(String)
options[:expires] = Time.parse(options[:expires])
end

if options[:expires].nil? || Time.now.utc > Time.parse(options[:expires])
if options[:expires].nil? || Time.now.utc > options[:expires]
raise MultiPass::ExpiredError.new(data, json, options)
end

Expand Down

0 comments on commit 2f909bf

Please sign in to comment.