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 CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NmVmYTYxMjdjYjFjNzQ3NDZlMmY1NTU4MzNlNjE0ZDE2MzYyMTA1Mg==
4
+ ZTE2NjNiZThjNjRjZDUxZDJjODA0N2UyOTNhYTk5MzRlOTgwYTNmNA==
5
5
  data.tar.gz: !binary |-
6
- NWFlM2YxZWI2Y2FjODRhNWVjYzg0ZTIyNDgyOGM4MWMzMTAyZGI4Yg==
6
+ NGEzZGY5NmQ5ZTAxMGM0Njc2MzRmMTY2MGQ0ODM5MWQwNDUzOTFhYw==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- NTExZjYzODQwYjgwYjNjNTY4MTQzNzNkOTMzMjQ4NjA1ZTZmNmFhYWVkYjBm
10
- Y2FmOGU2ZGFjZTljNDdjOGI4NmI1MTg2YzhhZmZlMjJiNmQyZGIwM2YwYTA1
11
- ZTcyYzRmNDEzOGRkZDIzYTIxYTg5NmUwZjY1MjRkYzVhMzdhMWI=
9
+ YTA3NmNhNGRlODYxYzk1NThiZWQ2YTVmNTg0NTYwMzRhZTM0M2NmM2I2NDhl
10
+ Mzc2ZjQzZTE1NzRlYjEzODAyZGEyNjlkMjA2ZjFkYmUwOGQzNGE0ODk2N2Vm
11
+ YWRiZWY2NGYxNmFhZDU1OTU2ZmU3NDBjOTg1YTkyMzA4NDYzY2Y=
12
12
  data.tar.gz: !binary |-
13
- MGNiNjhjODJmMzk1M2RkNDlkOTBkYzE3OTk1NmE4YjBhODBiYmIyNjRlNmM4
14
- OWU2YzYyNmE4NTViZTBmMGUxNzFkYWZlYjljODllZDU4OTUzNDRlMmJkZjI5
15
- MTRjYjk2MTUxNGRkOGRlZjZkMzllNmFiYzBlODZjMWJiYTFhNTg=
13
+ Zjg5ZTZmNWMyZWFhNzdlMDk3ZDM3Y2YzYjdhMjRlZDU1NGRlNjgyNTI5MTVj
14
+ MTViNjU4YTcwZjJlMTBmMTJlYTg5NzdjOThiNDhmNTBkN2ZjMzhlMGNkNjhi
15
+ OTc2NzgxNTg5OWVhNDY4YTU3ZWIyYTc4ZmVlODI5MDFlMjk4Y2I=
@@ -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.7.1"
2
+ VERSION = "0.7.2"
3
3
  end
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.1
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-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