nested-hstore 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -18,7 +18,7 @@ post.my_hstore = {
18
18
  'comment_ids' => [34, 67, 82],
19
19
  'user' => {
20
20
  'id' => 15,
21
- 'username' => 'janedoe',
21
+ 'username' => 'janedoe'
22
22
  }
23
23
  }
24
24
 
@@ -13,7 +13,11 @@ module ActiveRecord
13
13
  end
14
14
 
15
15
  def from_hstore hstore
16
- @nested_serializer.deserialize(super)
16
+ if ActiveRecord::VERSION::MAJOR >= 4
17
+ @nested_serializer.deserialize(hstore)
18
+ else
19
+ @nested_serializer.deserialize(super)
20
+ end
17
21
  end
18
22
  end
19
23
  end
@@ -103,11 +103,10 @@ module NestedHstore
103
103
  # This isn't ideal: how do we know whether each value in an hstore is JSON or a
104
104
  # string/integer/etc?
105
105
  def decode_json_if_json(value)
106
- begin
107
- ActiveSupport::JSON.decode(value)
108
- rescue
109
- value
110
- end
106
+ return value unless value.start_with?('{') && value.end_with?('}')
107
+ ActiveSupport::JSON.decode(value)
108
+ rescue
109
+ value
111
110
  end
112
111
 
113
112
  def encode_json(value)
@@ -1,3 +1,3 @@
1
1
  module NestedHstore
2
- VERSION = '0.0.1'
2
+ VERSION = '0.0.2'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nested-hstore
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-11-03 00:00:00.000000000 Z
12
+ date: 2014-02-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activerecord