jserializer 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 +4 -4
- data/lib/jserializer/base.rb +6 -4
- data/lib/jserializer.rb +1 -1
- metadata +2 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1d87f4dc464c30f4e4d7f1655e0019101239f8f7
|
4
|
+
data.tar.gz: d0f5b36f117596ad250a4bef5610365f6ca1a5da
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8f314d8efac6a860b2fde2c33fbb118adc42fc8aa7b0cc4f283efcf4c49ae290051f2df2e5e7517a48ae1db4d72263a51ae34063887e4e56d289697bbe13ab33
|
7
|
+
data.tar.gz: 8a6be0195282b6df82fa15da9d8390d99d5b3e0ed069acca7d2e6c01f273961cf624b3d22a41fbc17c2459ab31c951cce62e7624599a225bdb9df7cb9fb1b21a
|
data/lib/jserializer/base.rb
CHANGED
@@ -90,19 +90,21 @@ module Jserializer
|
|
90
90
|
end
|
91
91
|
end
|
92
92
|
|
93
|
-
attr_reader :object, :options, :
|
93
|
+
attr_reader :object, :options, :scope
|
94
|
+
|
95
|
+
alias :current_user :scope
|
94
96
|
|
95
97
|
# supported options:
|
96
98
|
# root:
|
97
99
|
# meta:
|
98
100
|
# meta_key:
|
99
|
-
# current_user:
|
101
|
+
# scope or current_user:
|
100
102
|
# is_collection:
|
101
103
|
# only: []
|
102
104
|
# except: []
|
103
105
|
def initialize(object, options = {})
|
104
106
|
@object = object
|
105
|
-
@
|
107
|
+
@scope = options[:scope] || options[:current_user]
|
106
108
|
@is_collection = options.delete(:is_collection) || false
|
107
109
|
@options = options
|
108
110
|
_update_attributes_filter
|
@@ -146,7 +148,7 @@ module Jserializer
|
|
146
148
|
end
|
147
149
|
|
148
150
|
def to_json(*)
|
149
|
-
|
151
|
+
JSON.generate(as_json)
|
150
152
|
end
|
151
153
|
|
152
154
|
# Returns a hash representation with the root
|
data/lib/jserializer.rb
CHANGED
metadata
CHANGED
@@ -1,29 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jserializer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Steven Yue
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-09-
|
11
|
+
date: 2018-09-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: oj
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - ">="
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '3.0'
|
20
|
-
type: :runtime
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - ">="
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '3.0'
|
27
13
|
- !ruby/object:Gem::Dependency
|
28
14
|
name: bundler
|
29
15
|
requirement: !ruby/object:Gem::Requirement
|