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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0911016f576d3cf46f9ef83a97f4eea75acadfbf
4
- data.tar.gz: dfecea376976d5c78310d018d9dfcf069bc586a6
3
+ metadata.gz: 750408c4938f35ca5abc691890dd714ce1c7c512
4
+ data.tar.gz: 0e384b50fedd31913467e8544d3a2883bd57c776
5
5
  SHA512:
6
- metadata.gz: 52bdc5c90da489fa0d346ccea4f7496bc0db839be9ff7015991cfe90350cf2bf1d1ca67322dd7da7e702829535a4b441b828cbfa8f6008d67e679cfc0e2b0c5e
7
- data.tar.gz: 1e6d13a18f3f0534df8a6a2fc35cda3b01937b388b1e72912b69102c1b87de6f1cb0ba37349b3e7a66bdc899b0337f33200d5c54b5adc438599c9fb9b98c46c2
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
- gem 'pry'
6
- gem 'contextuable', '~> 0.4'
7
- gem 'coveralls', require: false
8
- gem "codeclimate-test-reporter", group: :test, require: false
5
+ group :test do
6
+ gem 'pry'
7
+ gem 'dystruct', '~> 0.4'
8
+ gem 'simplecov'
9
+ gem 'coveralls'
10
+ end
@@ -24,5 +24,4 @@ Gem::Specification.new do |spec|
24
24
  spec.add_development_dependency "bundler", "~> 1.10"
25
25
  spec.add_development_dependency "rake", "~> 10.0"
26
26
  spec.add_development_dependency "rspec", "~> 3.3"
27
- spec.add_dependency 'activesupport', '~> 4.2'
28
27
  end
@@ -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
- config_accessor(:perform_caching) { false }
13
- config_accessor(:cache)
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
- Array.wrap(value).map { |o| nested_serialization!(o) }
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
@@ -1,8 +1,10 @@
1
1
  module EasySerializer
2
2
  class Base
3
3
  include Helpers
4
+ extend Forwardable
5
+
6
+ def_delegator :serialize, :to_json, :[]
4
7
 
5
- delegate :to_json, :[], to: :serialize
6
8
  attr_reader :object
7
9
  def initialize(object)
8
10
  @object = object
@@ -21,7 +21,11 @@ module EasySerializer
21
21
  end
22
22
 
23
23
  def options
24
- serializer.__cache.except(:block, :cache_key, :root_call, :serializer, :key)
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
@@ -1,3 +1,3 @@
1
1
  module EasySerializer
2
- VERSION = "0.2.1"
2
+ VERSION = "0.3.0"
3
3
  end
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.2.1
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: 2016-12-06 00:00:00.000000000 Z
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.4.5
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.