cyrax 0.5.3 → 0.5.4
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
- data/spec/cyrax/extensions/has_response_spec.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
|
+
OGQ4YmE2NmEyY2MyZTI5Mzk5MzgzOGJiYjg5ZDg3MjQwNDJhMWEwYw==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ODlkMmFkNWY3OTIwODc2Y2Y2NzFkMzA5Y2QyM2Y2MjZjYjMwNzNlYQ==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MzY3YWJiMjkxNjcxNjNlZjQ3ODY3ZTBiZTNhMjAxZmY1MDJiOTNiOGY3YTNk
|
10
|
+
NWJlYWUzOTI3N2E2MTk5YTJmYzVkMGVlYzMxYzhiYTczNzI5ZmQ2N2NkOTcy
|
11
|
+
NWRkMjk4OWRhY2VlNDNiMjNjMTViZmFjZjVmODE5ODIwY2I1ODg=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ZDFkYTc1NDdkMWU1YzdmNTE4YmQwMmMxODY5ODc2ZTNhOWU2YTc0NTYwMzRk
|
14
|
+
Y2M4OGNkMTBhN2Q1OTE1YmQ0MDkyNzg1MjI2ODc2MWFjZjA3MWQxMzkwZWY4
|
15
|
+
MjdlODJkNzllMDFlYTdkMGFkNzc3YmM2NjcxNGE0ZmEzNjRiNWI=
|
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
@@ -59,7 +59,7 @@ module Cyrax
|
|
59
59
|
describe '#respond_with' do
|
60
60
|
before { subject.stub(:response_name).and_return(:foo) }
|
61
61
|
it 'calls Cyrax::Response' do
|
62
|
-
Cyrax::Response.should_receive(:new).with(:foo, 'bar', {as: nil}).and_return(double.as_null_object)
|
62
|
+
Cyrax::Response.should_receive(:new).with(:foo, 'bar', {as: nil, assignments: nil}).and_return(double.as_null_object)
|
63
63
|
subject.respond_with('bar')
|
64
64
|
end
|
65
65
|
|
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.5.
|
4
|
+
version: 0.5.4
|
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
|