pragmatic_serializer 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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ca1d512ed0627c1415e081f0f329ed004cb5ee1e
|
4
|
+
data.tar.gz: ff94902167c944b2ba87f518f05aa735218eeef8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e1d78a092027b7143d0f52f03782102649c934e16c126630762e227952000411d26a00c858e5a791f1fa3c54320223c46b7aced93024fc76de3a0822440a35c2
|
7
|
+
data.tar.gz: c03d3716f5394baa51d743237a1ef8d4e481e7e64336071c6dda4edca567588d9f2009f992cce841140c3f56ac46aeb9753df6078ef7fd885728f13703d3ed9a
|
@@ -7,6 +7,7 @@ module PragmaticSerializer
|
|
7
7
|
base.send(:include, PragmaticSerializer::GeneralBaseJSON)
|
8
8
|
base.send(:include, PragmaticSerializer::GeneralResourceJSON)
|
9
9
|
base.send(:include, PragmaticSerializer::CollectionInterface)
|
10
|
+
base.send(:include, PragmaticSerializer::ResourceInterface)
|
10
11
|
end
|
11
12
|
end
|
12
13
|
end
|
@@ -7,6 +7,17 @@ module PragmaticSerializer
|
|
7
7
|
.tap { |cs| cs.resources = resources }
|
8
8
|
.tap { |cs| cs.resource_options = resource_options }
|
9
9
|
end
|
10
|
+
|
11
|
+
def collection_hash(resources, method=nil, resource_options: {})
|
12
|
+
collection(resources, resource_options: resource_options)
|
13
|
+
.tap do |cs|
|
14
|
+
# if method is specified pass it as serailzation method
|
15
|
+
# othervise the CollectionSerializer will use config.default_resource_serialization_method
|
16
|
+
# which is by default :as_json
|
17
|
+
cs.serialization_method = method if method
|
18
|
+
end
|
19
|
+
.as_json
|
20
|
+
end
|
10
21
|
end
|
11
22
|
|
12
23
|
def self.included(base)
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module PragmaticSerializer
|
2
|
+
module ResourceInterface
|
3
|
+
module ClassMethods
|
4
|
+
# initialize new resource serializer
|
5
|
+
#
|
6
|
+
# this method exist for consistency purpose with CollectionInterface
|
7
|
+
def resource(resource)
|
8
|
+
self.new(resource)
|
9
|
+
end
|
10
|
+
|
11
|
+
def resource_hash(resource, method=:as_json)
|
12
|
+
resource(resource).send(method)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.included(base)
|
17
|
+
base.send(:extend, ClassMethods)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
data/lib/pragmatic_serializer.rb
CHANGED
@@ -12,7 +12,9 @@ require "pragmatic_serializer/general_resource_json"
|
|
12
12
|
|
13
13
|
require "pragmatic_serializer/pagination_json"
|
14
14
|
require "pragmatic_serializer/collection_serializer"
|
15
|
+
|
15
16
|
require "pragmatic_serializer/collection_interface"
|
17
|
+
require "pragmatic_serializer/resource_interface"
|
16
18
|
|
17
19
|
require "pragmatic_serializer/all"
|
18
20
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pragmatic_serializer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tomas Valent
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-10-
|
11
|
+
date: 2016-10-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -109,6 +109,7 @@ files:
|
|
109
109
|
- lib/pragmatic_serializer/general_resource_json.rb
|
110
110
|
- lib/pragmatic_serializer/pagination_json.rb
|
111
111
|
- lib/pragmatic_serializer/prefixes.rb
|
112
|
+
- lib/pragmatic_serializer/resource_interface.rb
|
112
113
|
- lib/pragmatic_serializer/version.rb
|
113
114
|
- pragmatic_serializer.gemspec
|
114
115
|
homepage: https://github.com/equivalent/pragmatic_serializer
|