dm-pg-json 0.0.1 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/dm-pg-json/property/pgjson.rb +25 -4
- data/lib/dm-pg-json/version.rb +1 -1
- data/lib/dm-pg-json.rb +4 -7
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: daef494f25f8cb172e8c96527a943be8682e2486
|
4
|
+
data.tar.gz: c24e17c869fc9a320d0d98265663e4587604970e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1fdc00f2e015e1d7d6747ad1dcd2e126bd2c5c5c939aa78bb80c43e13bb925c1c5ddcf8ba10f43e3e0bb6c0b088ca0f24881938dbfd256ed8d2dc04b96fe1b1c
|
7
|
+
data.tar.gz: acbd90f9afd862aa618e15ab0d8467f46c85f254f587927e9212b94e07cdb44670c13bcc69d8148649d497fa4dda56fd8c2450e0d28dc5086e0c08d0921e22ad
|
@@ -1,14 +1,35 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
+
require 'dm-core'
|
4
|
+
require 'dm-types/support/dirty_minder'
|
5
|
+
|
3
6
|
module DataMapper
|
4
7
|
class Property
|
5
|
-
class PgJSON <
|
8
|
+
class PgJSON < Text
|
9
|
+
def dump(value)
|
10
|
+
case value
|
11
|
+
when ::NilClass, ::String
|
12
|
+
value
|
13
|
+
when ::Hash, ::Array
|
14
|
+
Oj.dump(value, mode: :compat)
|
15
|
+
else
|
16
|
+
'{}'
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
6
20
|
def load(value)
|
7
|
-
|
21
|
+
case value
|
22
|
+
when ::Hash, ::Array
|
23
|
+
value
|
24
|
+
when ::String
|
25
|
+
Oj.load(value)
|
26
|
+
else
|
27
|
+
{}
|
28
|
+
end
|
8
29
|
end
|
9
30
|
|
10
|
-
def
|
11
|
-
|
31
|
+
def primitive?(value)
|
32
|
+
value.kind_of?(::String)
|
12
33
|
end
|
13
34
|
end
|
14
35
|
end
|
data/lib/dm-pg-json/version.rb
CHANGED
data/lib/dm-pg-json.rb
CHANGED
@@ -2,19 +2,16 @@
|
|
2
2
|
|
3
3
|
require 'dm-core'
|
4
4
|
require 'dm-postgres-adapter'
|
5
|
+
require 'dm-pg-json/property/pgjson'
|
5
6
|
require 'dm-pg-json/version'
|
6
7
|
|
7
8
|
module DataMapper
|
8
|
-
class Property
|
9
|
-
autoload :PgJSON, 'dm-pg-json/property/pgjson'
|
10
|
-
end
|
11
|
-
|
12
9
|
module Migrations
|
13
10
|
module PostgresAdapter
|
14
11
|
def property_schema_hash(property)
|
15
12
|
schema = super
|
16
13
|
|
17
|
-
if property.kind_of?(Property::PgJSON)
|
14
|
+
if property.kind_of?(::DataMapper::Property::PgJSON)
|
18
15
|
schema.delete(:length)
|
19
16
|
end
|
20
17
|
|
@@ -35,9 +32,9 @@ module DataMapper
|
|
35
32
|
#
|
36
33
|
# @api private
|
37
34
|
def type_map
|
38
|
-
super.merge(Property::PgJSON => {:primitive => 'JSON'}).freeze
|
35
|
+
super.merge(::DataMapper::Property::PgJSON => {:primitive => 'JSON'}).freeze
|
39
36
|
end
|
40
37
|
end
|
41
38
|
end
|
42
39
|
end
|
43
|
-
DataMapper::Adapters::PostgresAdapter.send(:include,DataMapper::PostgresJSON)
|
40
|
+
DataMapper::Adapters::PostgresAdapter.send(:include, ::DataMapper::PostgresJSON)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dm-pg-json
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- StyleSeek Engineering Team
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-12-
|
11
|
+
date: 2013-12-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dm-core
|