mongoid-time_with_named_zone 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f73cc1515f962a4f7b277a17338b4d4a3439c547
4
- data.tar.gz: 6d63ec9f1e9f71815106d9bccd054f75e6b1f9a1
3
+ metadata.gz: 0a57b966d50562922af60e9abeb585d031826bc4
4
+ data.tar.gz: b17f8b520e92bdd9a47e23d38f5b07c69cca4b55
5
5
  SHA512:
6
- metadata.gz: 91a6d4c816197825b2845cd230362e647f707a597b6bc797195ca02bd8b4a17b0e56bd95c01f6644f37c2f7a0086c3046539e781ac46aabd22ed176b95135cce
7
- data.tar.gz: 867a786d45e980689b993ada146a13b4dd56cc583c5916d5c9c020e92214920a028a9e691f211662f35080bf1ea2f3481df7af77932772175b82922a3bf63542
6
+ metadata.gz: 385f2dd028b7a8384ce61cea0480fd0410e317102f5ccd1ec549301e40d31df7fda7ac10812c79d7ddfb91787a697dd6b32c7863a12ce60dadd06f7af082b2a3
7
+ data.tar.gz: e394289fc108e3b6341111ecddcdbea1c7d867643edfa8de9aec8cef3ec741f5a9979fdd78c60a24f0b797969162d99ceb9be827500648ac5962bb0b69080e91
@@ -9,8 +9,10 @@ module Mongoid
9
9
  class << self
10
10
  # Convert the object from its mongo friendly ruby type to this type
11
11
  def demongoize(object)
12
- return nil unless object && object['time'] && object['zone']
13
- object['time'].in_time_zone(object['zone'])
12
+ return nil unless object.is_a? Hash
13
+ object.symbolize_keys!
14
+ return nil unless object[:time] && object[:zone]
15
+ object[:time].in_time_zone(object[:zone])
14
16
  end
15
17
 
16
18
  # Turn the object from the ruby type we deal with to a Mongo friendly type
@@ -1,5 +1,5 @@
1
1
  module Mongoid
2
2
  module TimeWithNamedZone
3
- VERSION = '0.2.0'.freeze
3
+ VERSION = '0.2.1'.freeze
4
4
  end
5
5
  end
@@ -32,6 +32,12 @@ describe Mongoid::TimeWithNamedZone do
32
32
  expect(demongoized_value).to eq(Time.new(2010, 11, 19, '+13:00'))
33
33
  end
34
34
 
35
+ it 'works with symbolized keys' do
36
+ hash = { time: Time.utc(2010, 11, 19), zone: 'Pacific/Auckland' }
37
+ demongoized_value = Mongoid::TimeWithNamedZone.demongoize(hash)
38
+ expect(demongoized_value).to eq(Time.new(2010, 11, 19, '+13:00'))
39
+ end
40
+
35
41
  it 'returns nil for blank object' do
36
42
  expect(Mongoid::TimeWithNamedZone.demongoize(nil)).to eq(nil)
37
43
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongoid-time_with_named_zone
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Carnival Mobile