simple-serializer 0.1.5 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/simple_serializer.rb +5 -5
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '0529a9f40cbaf4119586e1a99bf2f2286d619b636293a6648e3cdf07f80dc2a7'
|
4
|
+
data.tar.gz: 5ae69830b9b2ae5619e23790cee691d7d37bdaa8e6c6e525b5620d28484298c3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a76c5f61ab628d1fe0a93ffdb9266e33feedae0ba7b8790a29616302cb1e7b3696852698284892ec384eee79a63b2048409713591fe362bdec3f016b6475702a
|
7
|
+
data.tar.gz: 485182001fcf8843d2f18287a362735b4b79900a82cdda10ebdd1cffc87022284d78c53a30a88ecd1de6424ae096f92270a28bc1bb426377669b11bd6f1254ce
|
data/lib/simple_serializer.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
class SimpleSerializer
|
4
|
-
VERSION = '0.1.
|
4
|
+
VERSION = '0.1.6'
|
5
5
|
|
6
6
|
def initialize(object, opts = {})
|
7
7
|
@include = opts[:include] || []
|
@@ -27,9 +27,9 @@ class SimpleSerializer
|
|
27
27
|
|
28
28
|
Module.new.tap do |m|
|
29
29
|
m.define_singleton_method(:included) do |base|
|
30
|
-
base.define_method(:to_h) { serializer.to_h(self) }
|
30
|
+
base.define_method(:to_h) { |o = {}| serializer.to_h(self, o) }
|
31
31
|
|
32
|
-
base.define_method(:to_json) { serializer.to_json(self) }
|
32
|
+
base.define_method(:to_json) { |o = {}| serializer.to_json(self, o) }
|
33
33
|
|
34
34
|
base.define_method(:serializer_class) { serializer }
|
35
35
|
end
|
@@ -44,8 +44,8 @@ class SimpleSerializer
|
|
44
44
|
new(object, opts).to_h
|
45
45
|
end
|
46
46
|
|
47
|
-
def to_json(object)
|
48
|
-
to_h(object).to_json
|
47
|
+
def to_json(object, opts = {})
|
48
|
+
to_h(object, opts).to_json
|
49
49
|
end
|
50
50
|
|
51
51
|
def attributes(*fields, **named, &block)
|