couchbase-id 1.0.4 → 1.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 76cad00122eedaa52d97d989e130faff4a9ce0eb
4
- data.tar.gz: c1883158b04f85e3315814b54a69cb2d7db801a5
3
+ metadata.gz: 17a624b57deb062a71a3d26c05d8002508e9397d
4
+ data.tar.gz: eecf62f4e9f3385252796cea40dee43035588792
5
5
  SHA512:
6
- metadata.gz: 62176c3dc63b501089916f75761c6a715589f026f90eac885c01873c1b1109f6dc49d2797e418faaa93aceb0741deddb8454fadc1af08ff621e1082a3f5468e1
7
- data.tar.gz: 5ccba7537d9cb5b6cc72b4594154af643c14fc92d679b69da2fe976f7bc7da7f05b66aa38dcf37dffe10567525f0568c79a4e4c951ab7019448df4b949e5a6b7
6
+ metadata.gz: 5ea51e602a1522fe81ee1b76e11ccdd721a651f19081342bb32fd02d00b68eb95cae1fc7dd605311af1e3e16bebc3fda4f5e513bdc2f9554b0286660ce910c8f
7
+ data.tar.gz: 42525f06fc2df7cf0008c095b936870764ac25bea5270f11f683e29a7eed12f144968e185aa4f09271a083194b79d4e0df5360f3192b29131fb08f633979855c
@@ -38,14 +38,14 @@ module CouchbaseId
38
38
  #
39
39
  # Generate the id (incrementing values as required)
40
40
  #
41
- overflow = self.class.__overflow__ ||= self.class.bucket.get("#{self.class.__class_name__}:#{CLUSTER_ID}:overflow", :quiet => true) # Don't error if not there
42
- count = self.class.bucket.incr("#{self.class.__class_name__}:#{CLUSTER_ID}:count", :create => true) # This models current id count
41
+ overflow = self.class.__overflow__ ||= self.class.bucket.get("#{self.class.design_document}:#{CLUSTER_ID}:overflow", :quiet => true) # Don't error if not there
42
+ count = self.class.bucket.incr("#{self.class.design_document}:#{CLUSTER_ID}:count", :create => true) # This models current id count
43
43
  if count == 0 || overflow.nil?
44
44
  overflow ||= 0
45
45
  overflow += 1
46
46
  # We shouldn't need to worry about concurrency here due to the size of count
47
47
  # Would require ~18446744073709551615 concurrent writes
48
- self.class.bucket.set("#{self.class.__class_name__}:#{CLUSTER_ID}:overflow", overflow)
48
+ self.class.bucket.set("#{self.class.design_document}:#{CLUSTER_ID}:overflow", overflow)
49
49
  self.class.__overflow__ = overflow
50
50
  end
51
51
 
@@ -63,8 +63,8 @@ module CouchbaseId
63
63
  while self.class.bucket.get(self.id, :quiet => true).present?
64
64
  # Set in-case we are here due to a crash (concurrency is not an issue)
65
65
  # Note we are not incrementing the @__overflow__ variable
66
- self.class.bucket.set("#{self.class.__class_name__}:#{CLUSTER_ID}:overflow", overflow + 1)
67
- count = self.class.bucket.incr("#{self.class.__class_name__}:#{CLUSTER_ID}:count") # Increment just in case (attempt to avoid infinite loops)
66
+ self.class.bucket.set("#{self.class.design_document}:#{CLUSTER_ID}:overflow", overflow + 1)
67
+ count = self.class.bucket.incr("#{self.class.design_document}:#{CLUSTER_ID}:count") # Increment just in case (attempt to avoid infinite loops)
68
68
 
69
69
  # Reset the overflow
70
70
  if self.class.__overflow__ == overflow
@@ -81,7 +81,6 @@ module CouchbaseId
81
81
  class << base
82
82
  attr_accessor :__overflow__
83
83
  attr_accessor :__class_id_generator__
84
- attr_accessor :__class_name__
85
84
  end
86
85
 
87
86
 
@@ -96,7 +95,7 @@ module CouchbaseId
96
95
 
97
96
  def self.default_class_id_generator(overflow, count)
98
97
  id = Radix.convert([overflow, CLUSTER_ID].join.to_i, B10, B65) + Radix.convert(count, B10, B65)
99
- "#{self.__class_name__}-#{id}"
98
+ "#{self.design_document}-#{id}"
100
99
  end
101
100
 
102
101
  #
@@ -111,7 +110,6 @@ module CouchbaseId
111
110
  # Configure class level variables
112
111
  base.__overflow__ = nil
113
112
  base.__class_id_generator__ = method(:default_class_id_generator)
114
- base.__class_name__ = self.name.underscore.gsub(/\/|_/, '-') # The included classes name
115
113
  end
116
114
  end
117
115
  end # END:: Generator
@@ -1,3 +1,3 @@
1
1
  module CouchbaseId
2
- VERSION = '1.0.4'
2
+ VERSION = '1.0.5'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: couchbase-id
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.4
4
+ version: 1.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stephen von Takach
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-12-04 00:00:00.000000000 Z
11
+ date: 2013-12-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: couchbase-model