plucker_serializer 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/plucker/base.rb +1 -1
- data/lib/plucker/collection.rb +2 -0
- data/lib/plucker/{caching.rb → concerns/caching.rb} +4 -7
- data/lib/plucker/configuration.rb +11 -0
- data/lib/plucker/version.rb +1 -1
- data/lib/plucker_serializer.rb +14 -1
- metadata +12 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 98c18aa3e96729279436e2e8e51f1fdd9b000927239dae2d4d269f42b2888314
|
4
|
+
data.tar.gz: 51a38fe79f8d167c6caf3a7d532c007dac88530c0bdd191e72137bd114e6c652
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e42c772ff7b205cf92e3cf75c8d6bfa9f6de7b931c70684651bef6e0c5e77ce2e9376862f907fbae2e60e78f1acf9e83f6f15ae57ab914a1326199f296fa85a1
|
7
|
+
data.tar.gz: 2a183004a3a9217880cc172e88c46713afd2a450f201e390b475892dbcc13521ca3b298dffdcb295af31a880a53816437774c109ceff33ffae527df59c5fdae2
|
data/lib/plucker/base.rb
CHANGED
data/lib/plucker/collection.rb
CHANGED
@@ -9,6 +9,7 @@ module Plucker
|
|
9
9
|
with_options instance_writer: false, instance_reader: false do |serializer|
|
10
10
|
serializer.class_attribute :_cache
|
11
11
|
serializer.class_attribute :_cache_options
|
12
|
+
serializer.class_attribute :_cache_store
|
12
13
|
end
|
13
14
|
end
|
14
15
|
|
@@ -20,22 +21,18 @@ module Plucker
|
|
20
21
|
|
21
22
|
def cache(options = {})
|
22
23
|
self._cache = true
|
24
|
+
self._cache_store = Plucker.config.cache_store || ActiveSupport::Cache.lookup_store(:null_store)
|
23
25
|
self._cache_options = options.blank? ? {} : options
|
24
26
|
end
|
25
27
|
|
26
|
-
def cache_store
|
27
|
-
defined?(Rails) && Rails.cache
|
28
|
-
end
|
29
|
-
|
30
28
|
def cache_enabled?
|
31
|
-
|
29
|
+
self._cache_store.present? && _cache.present?
|
32
30
|
end
|
33
31
|
end
|
34
32
|
|
35
|
-
### INSTANCE METHODS
|
36
33
|
def fetch
|
37
34
|
if serializer_class.cache_enabled?
|
38
|
-
|
35
|
+
self.class._cache_store.fetch(cache_key, version: cache_version, options: serializer_class._cache_options) do
|
39
36
|
yield
|
40
37
|
end
|
41
38
|
else
|
data/lib/plucker/version.rb
CHANGED
data/lib/plucker_serializer.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require "plucker/version"
|
2
|
+
require "plucker/configuration"
|
2
3
|
require "plucker/base"
|
3
4
|
require "plucker/attribute"
|
4
5
|
require "plucker/collection"
|
@@ -8,4 +9,16 @@ require "plucker/has_one"
|
|
8
9
|
require "plucker/has_many"
|
9
10
|
require "plucker/field"
|
10
11
|
require "plucker/descriptor"
|
11
|
-
require "plucker/caching"
|
12
|
+
require "plucker/concerns/caching"
|
13
|
+
|
14
|
+
module Plucker
|
15
|
+
class << self
|
16
|
+
def config
|
17
|
+
@config ||= Configuration.new
|
18
|
+
end
|
19
|
+
|
20
|
+
def configure
|
21
|
+
yield(config)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: plucker_serializer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Henry Boisgibault
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-08-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -24,7 +24,7 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
|
-
description: A blazing fast JSON serializer
|
27
|
+
description: A blazing fast JSON serializer for ActiveRecord & Ruby objects
|
28
28
|
email: henry@logora.fr
|
29
29
|
executables: []
|
30
30
|
extensions: []
|
@@ -33,8 +33,9 @@ files:
|
|
33
33
|
- lib/plucker/attribute.rb
|
34
34
|
- lib/plucker/base.rb
|
35
35
|
- lib/plucker/belongs_to.rb
|
36
|
-
- lib/plucker/caching.rb
|
37
36
|
- lib/plucker/collection.rb
|
37
|
+
- lib/plucker/concerns/caching.rb
|
38
|
+
- lib/plucker/configuration.rb
|
38
39
|
- lib/plucker/descriptor.rb
|
39
40
|
- lib/plucker/field.rb
|
40
41
|
- lib/plucker/has_many.rb
|
@@ -42,10 +43,14 @@ files:
|
|
42
43
|
- lib/plucker/relationship.rb
|
43
44
|
- lib/plucker/version.rb
|
44
45
|
- lib/plucker_serializer.rb
|
45
|
-
homepage:
|
46
|
+
homepage: https://github.com/plucker-serializer/plucker_serializer
|
46
47
|
licenses:
|
47
48
|
- MIT
|
48
|
-
metadata:
|
49
|
+
metadata:
|
50
|
+
bug_tracker_uri: https://github.com/plucker-serializer/plucker_serializer/issues
|
51
|
+
source_code_uri: https://github.com/plucker-serializer/plucker_serializer
|
52
|
+
documentation_uri: https://github.com/plucker-serializer/plucker_serializer
|
53
|
+
changelog_uri: https://github.com/plucker-serializer/plucker_serializer/releases
|
49
54
|
post_install_message:
|
50
55
|
rdoc_options: []
|
51
56
|
require_paths:
|
@@ -64,5 +69,5 @@ requirements: []
|
|
64
69
|
rubygems_version: 3.1.2
|
65
70
|
signing_key:
|
66
71
|
specification_version: 4
|
67
|
-
summary: A blazing fast JSON serializer
|
72
|
+
summary: A blazing fast JSON serializer for ActiveRecord & Ruby objects
|
68
73
|
test_files: []
|