cyrax 0.7.1 → 0.7.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/lib/cyrax/serializer.rb +23 -0
- data/lib/cyrax/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ZTE2NjNiZThjNjRjZDUxZDJjODA0N2UyOTNhYTk5MzRlOTgwYTNmNA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NGEzZGY5NmQ5ZTAxMGM0Njc2MzRmMTY2MGQ0ODM5MWQwNDUzOTFhYw==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
YTA3NmNhNGRlODYxYzk1NThiZWQ2YTVmNTg0NTYwMzRhZTM0M2NmM2I2NDhl
|
10
|
+
Mzc2ZjQzZTE1NzRlYjEzODAyZGEyNjlkMjA2ZjFkYmUwOGQzNGE0ODk2N2Vm
|
11
|
+
YWRiZWY2NGYxNmFhZDU1OTU2ZmU3NDBjOTg1YTkyMzA4NDYzY2Y=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
Zjg5ZTZmNWMyZWFhNzdlMDk3ZDM3Y2YzYjdhMjRlZDU1NGRlNjgyNTI5MTVj
|
14
|
+
MTViNjU4YTcwZjJlMTBmMTJlYTg5NzdjOThiNDhmNTBkN2ZjMzhlMGNkNjhi
|
15
|
+
OTc2NzgxNTg5OWVhNDY4YTU3ZWIyYTc4ZmVlODI5MDFlMjk4Y2I=
|
data/lib/cyrax/serializer.rb
CHANGED
@@ -1,14 +1,37 @@
|
|
1
1
|
class Cyrax::Serializer < Cyrax::Wrapper
|
2
2
|
def serialize
|
3
3
|
options[:serializer] = self
|
4
|
+
|
5
|
+
if block = self.class.total_count_block
|
6
|
+
serialize_wrapped(options, &block)
|
7
|
+
else
|
8
|
+
serialize_simple(options)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def serialize_simple(options = {})
|
4
13
|
self.class.scope.serialize(resource, options)
|
5
14
|
end
|
6
15
|
|
16
|
+
def serialize_wrapped(options = {}, &counter_block)
|
17
|
+
total_count = self.instance_eval(&counter_block)
|
18
|
+
data = self.class.scope.serialize(resource, options)
|
19
|
+
{total_count: total_count, data: data}
|
20
|
+
end
|
21
|
+
|
7
22
|
class << self
|
8
23
|
def scope
|
9
24
|
@scope ||= Cyrax::Serializers::Scope.new()
|
10
25
|
end
|
11
26
|
|
27
|
+
def total_count(&block)
|
28
|
+
@total_count_block = block
|
29
|
+
end
|
30
|
+
|
31
|
+
def total_count_block
|
32
|
+
@total_count_block
|
33
|
+
end
|
34
|
+
|
12
35
|
def namespace(name, &block)
|
13
36
|
scope.namespace(name, &block)
|
14
37
|
end
|
data/lib/cyrax/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cyrax
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Droidlabs
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-03-
|
11
|
+
date: 2014-03-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|