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 CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NmIyODJjMDljMjllMmJkNzM0YmM4ZTY3ZDE5OGFjMTBhYjZjZTRkNQ==
4
+ OGQ4YmE2NmEyY2MyZTI5Mzk5MzgzOGJiYjg5ZDg3MjQwNDJhMWEwYw==
5
5
  data.tar.gz: !binary |-
6
- MjU3NTYzNWU4NGMwNWJlYjNiYjFkOTRmNzM1YjUxMjgyN2E3YTcxNw==
6
+ ODlkMmFkNWY3OTIwODc2Y2Y2NzFkMzA5Y2QyM2Y2MjZjYjMwNzNlYQ==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- MjYzNWRkNDlhMGRkN2YyOWU3NzlkYjI3YWFkNmVmYmRmNTRiNzY2NTQzZTIx
10
- Y2E1OTJmMWI4NTUwMzBkYzg4YmM4NDgyZGNkMjk2YTEwOWE3MDM5NDhjNmIy
11
- YmRhZTVjZDdkYTljZTQ3Njc3OWM3MmNlOGM5NDhiZDllMDllYTg=
9
+ MzY3YWJiMjkxNjcxNjNlZjQ3ODY3ZTBiZTNhMjAxZmY1MDJiOTNiOGY3YTNk
10
+ NWJlYWUzOTI3N2E2MTk5YTJmYzVkMGVlYzMxYzhiYTczNzI5ZmQ2N2NkOTcy
11
+ NWRkMjk4OWRhY2VlNDNiMjNjMTViZmFjZjVmODE5ODIwY2I1ODg=
12
12
  data.tar.gz: !binary |-
13
- N2Q2MjYyYzViNjljM2I4ZWYyZjYwYTM5ZDNhMjZjNjk4YWJjMmVlODAwMDRj
14
- N2RjZmE1ZGQwMjcyNDBiNWY3MWU3ZDQzODI3YTZkNjliMTdhYTMxMTVjMjQ5
15
- NjFlZGZiNGQ1ODM3OWViN2QxNmNlODQyMmZmZTllODc4MmE4MTA=
13
+ ZDFkYTc1NDdkMWU1YzdmNTE4YmQwMmMxODY5ODc2ZTNhOWU2YTc0NTYwMzRk
14
+ Y2M4OGNkMTBhN2Q1OTE1YmQ0MDkyNzg1MjI2ODc2MWFjZjA3MWQxMzkwZWY4
15
+ MjdlODJkNzllMDFlYTdkMGFkNzc3YmM2NjcxNGE0ZmEzNjRiNWI=
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Cyrax
2
- VERSION = "0.5.3"
2
+ VERSION = "0.5.4"
3
3
  end
@@ -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.3
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-12 00:00:00.000000000 Z
11
+ date: 2014-03-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport