pragmatic_serializer 0.1.0 → 0.2.0
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: 8459cbb6e538aea800ea54a28f6c0af9b077139e
|
4
|
+
data.tar.gz: 95149a2b02c694c1aa9facbdf03a84a3dcc51000
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ed6ba603de3183efe1b893df58225b76532d9d379550517ea789724cade12e46afd78a9786aaf6fb9579679dd72b598c39cce2f4c972747cb8d642b545f781da
|
7
|
+
data.tar.gz: f74a3dd99aace5e9f9dbd2110866916bc673d5923da7b93bbf49c487e683351f339dab17e88a75a548eb16948818bad45dbd9bfdd765a3be4c98d10fa5aa1f79
|
data/README.md
CHANGED
@@ -23,7 +23,7 @@ Also the gem don't extend anything Rails wise (therefore Sinatra can use
|
|
23
23
|
it too), it just provides a generic
|
24
24
|
way to build Plain Ruby Object Serializers that you can call `as_json`
|
25
25
|
on to produce hash that you can then pass to `render json:
|
26
|
-
DocumentSerializer.new(
|
26
|
+
DocumentSerializer.new(Document.last).as_json`
|
27
27
|
|
28
28
|
## Installation
|
29
29
|
|
@@ -33,11 +33,11 @@ module PragmaticSerializer
|
|
33
33
|
end
|
34
34
|
|
35
35
|
private
|
36
|
-
def_delegators :resource_serializer, :
|
36
|
+
def_delegators :resource_serializer, :collection_prefix
|
37
37
|
|
38
38
|
def collection_serializers
|
39
39
|
resources.map do |resource|
|
40
|
-
resource_object = resource_serializer.new(
|
40
|
+
resource_object = resource_serializer.new(resource)
|
41
41
|
|
42
42
|
resource_options.each do |method_name, value|
|
43
43
|
resource_object.send(method_name, value)
|
@@ -1,14 +1,11 @@
|
|
1
1
|
module PragmaticSerializer
|
2
2
|
module GeneralInitialization
|
3
3
|
def self.included(base)
|
4
|
-
base.send(:attr_reader,
|
4
|
+
base.send(:attr_reader, :resource)
|
5
5
|
end
|
6
6
|
|
7
|
-
def initialize(
|
8
|
-
|
9
|
-
raise ArgumentError.new("missing keyword: #{x}")
|
10
|
-
end
|
11
|
-
instance_variable_set("@#{prefix}", value)
|
7
|
+
def initialize(resource)
|
8
|
+
@resource = resource
|
12
9
|
end
|
13
10
|
end
|
14
11
|
end
|