easy_serializer 0.2.1 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +6 -4
- data/easy_serializer.gemspec +0 -1
- data/lib/easy_serializer.rb +26 -15
- data/lib/easy_serializer/attribute_serializer.rb +2 -1
- data/lib/easy_serializer/base.rb +3 -1
- data/lib/easy_serializer/root_cacher.rb +5 -1
- data/lib/easy_serializer/version.rb +1 -1
- metadata +3 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 750408c4938f35ca5abc691890dd714ce1c7c512
|
4
|
+
data.tar.gz: 0e384b50fedd31913467e8544d3a2883bd57c776
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aaadf06233f1b56ac4ed26074d89a836abf8f18d5b76c7401d37d4eecfdfdfbe687198ee23d067229f0843fabd6313c8dcb1d307690bb8a421b48afee9ecb4b5
|
7
|
+
data.tar.gz: a315fec30af8d7984ecbc36ce840e2aa6b147640286b8f2f8201e765a3d48b08f4a5a6d2e3415bd4596c6b91c5203ac30c75548adeeef6d263d7ba8333ee89d5
|
data/Gemfile
CHANGED
@@ -2,7 +2,9 @@ source 'https://rubygems.org'
|
|
2
2
|
|
3
3
|
# Specify your gem's dependencies in easy_serializer.gemspec
|
4
4
|
gemspec
|
5
|
-
|
6
|
-
gem '
|
7
|
-
gem '
|
8
|
-
gem
|
5
|
+
group :test do
|
6
|
+
gem 'pry'
|
7
|
+
gem 'dystruct', '~> 0.4'
|
8
|
+
gem 'simplecov'
|
9
|
+
gem 'coveralls'
|
10
|
+
end
|
data/easy_serializer.gemspec
CHANGED
data/lib/easy_serializer.rb
CHANGED
@@ -1,24 +1,35 @@
|
|
1
1
|
require "easy_serializer/version"
|
2
|
-
require 'active_support/all'
|
3
2
|
|
4
3
|
module EasySerializer
|
5
|
-
include ActiveSupport::Configurable
|
6
|
-
extend ActiveSupport::Autoload
|
7
|
-
|
8
4
|
def self.setup
|
9
5
|
yield self
|
10
6
|
end
|
11
7
|
|
12
|
-
|
13
|
-
|
8
|
+
def self.perform_caching=(val)
|
9
|
+
@perform_caching = val
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.perform_caching
|
13
|
+
return @perform_caching if defined?(@perform_caching)
|
14
|
+
false
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.cache=(val)
|
18
|
+
@cache = val
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.cache
|
22
|
+
return @cache if defined?(@cache)
|
23
|
+
false
|
24
|
+
end
|
14
25
|
|
15
|
-
autoload :Helpers
|
16
|
-
autoload :Cacher
|
17
|
-
autoload :RootCacher
|
18
|
-
autoload :Attribute
|
19
|
-
autoload :AttributeSerializer
|
20
|
-
autoload :Base
|
21
|
-
autoload :CacheOutput
|
22
|
-
autoload :Field
|
23
|
-
autoload :Collection
|
24
26
|
end
|
27
|
+
require 'easy_serializer/helpers'
|
28
|
+
require 'easy_serializer/field'
|
29
|
+
require 'easy_serializer/cacher'
|
30
|
+
require 'easy_serializer/root_cacher'
|
31
|
+
require 'easy_serializer/attribute'
|
32
|
+
require 'easy_serializer/attribute_serializer'
|
33
|
+
require 'easy_serializer/cache_output'
|
34
|
+
require 'easy_serializer/collection'
|
35
|
+
require 'easy_serializer/base'
|
@@ -29,7 +29,8 @@ module EasySerializer
|
|
29
29
|
return value.output if value.is_a?(CacheOutput)
|
30
30
|
return value unless metadata.nested_serializer?
|
31
31
|
if metadata.is_a? Collection
|
32
|
-
|
32
|
+
ary = value.is_a?(Array) ? value : (value == nil ? [] : [value])
|
33
|
+
ary.map { |o| nested_serialization!(o) }
|
33
34
|
else
|
34
35
|
nested_serialization!(value)
|
35
36
|
end
|
data/lib/easy_serializer/base.rb
CHANGED
@@ -21,7 +21,11 @@ module EasySerializer
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def options
|
24
|
-
serializer.__cache.
|
24
|
+
h = serializer.__cache.dup
|
25
|
+
[:block, :cache_key, :root_call, :serializer, :key].each do |k|
|
26
|
+
h.delete(k)
|
27
|
+
end
|
28
|
+
h
|
25
29
|
end
|
26
30
|
|
27
31
|
def key
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: easy_serializer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Artur Pañach
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-01-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -52,20 +52,6 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '3.3'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: activesupport
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - "~>"
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '4.2'
|
62
|
-
type: :runtime
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - "~>"
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '4.2'
|
69
55
|
description: |-
|
70
56
|
EasySerializer is inspired in ActiveModel Serializer > 0.10 it's a
|
71
57
|
simple solution for a day to day work with APIs.
|
@@ -123,7 +109,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
123
109
|
version: '0'
|
124
110
|
requirements: []
|
125
111
|
rubyforge_project:
|
126
|
-
rubygems_version: 2.
|
112
|
+
rubygems_version: 2.5.2
|
127
113
|
signing_key:
|
128
114
|
specification_version: 4
|
129
115
|
summary: Semantic serializer for making easy serializing objects.
|