redpear 0.6.1 → 0.6.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/redpear/connection.rb +18 -7
- data/lib/redpear/namespace.rb +3 -3
- data/lib/redpear/nest.rb +12 -2
- data/lib/redpear/persistence.rb +1 -1
- metadata +13 -13
data/lib/redpear/connection.rb
CHANGED
@@ -3,15 +3,26 @@ module Redpear::Connection
|
|
3
3
|
|
4
4
|
module ClassMethods
|
5
5
|
|
6
|
-
# @return [Redis] the current connection
|
7
|
-
def
|
8
|
-
@
|
6
|
+
# @return [Redis] the current master connection
|
7
|
+
def master_connection
|
8
|
+
@master_connection ||= (superclass.respond_to?(:master_connection) ? superclass.master_connection : Redis.current)
|
9
9
|
end
|
10
|
+
alias_method :connection, :master_connection
|
10
11
|
|
11
|
-
# @param [Redis] the connection to assign
|
12
|
-
def
|
13
|
-
@
|
12
|
+
# @param [Redis] the master connection to assign
|
13
|
+
def master_connection=(value)
|
14
|
+
@master_connection = value
|
15
|
+
end
|
16
|
+
|
17
|
+
# @return [Redis] the current slave connection
|
18
|
+
def slave_connection
|
19
|
+
@slave_connection
|
20
|
+
end
|
21
|
+
|
22
|
+
# @param [Redis] the slave connection to assign
|
23
|
+
def slave_connection=(value)
|
24
|
+
@slave_connection = value
|
14
25
|
end
|
15
26
|
|
16
27
|
end
|
17
|
-
end
|
28
|
+
end
|
data/lib/redpear/namespace.rb
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
# end
|
6
6
|
# instance = Comment.save(:post_id => 2)
|
7
7
|
#
|
8
|
-
# Comment.
|
8
|
+
# Comment.namespace.keys
|
9
9
|
# # => ['comments:1', 'comments:+', 'comments:*', 'comments:post_id:2']
|
10
10
|
#
|
11
11
|
# # Instance nesting
|
@@ -31,10 +31,10 @@ module Redpear::Namespace
|
|
31
31
|
|
32
32
|
# @return [Redpear::Nest] the namespace of this model, Example:
|
33
33
|
#
|
34
|
-
# Comment.namespace # => "comments":Nest
|
34
|
+
# Comment.namespace # => "comments":Redpear::Nest
|
35
35
|
#
|
36
36
|
def namespace
|
37
|
-
@namespace ||= Redpear::Nest.new(scope,
|
37
|
+
@namespace ||= Redpear::Nest.new(scope, master_connection, slave_connection)
|
38
38
|
end
|
39
39
|
|
40
40
|
# @return [String] the scope of this model. Example:
|
data/lib/redpear/nest.rb
CHANGED
@@ -77,13 +77,23 @@ class Redpear::Nest < ::String
|
|
77
77
|
|
78
78
|
MASTER_METHODS.each do |meth|
|
79
79
|
define_method(meth) do |*args, &block|
|
80
|
-
|
80
|
+
client = current || master
|
81
|
+
if Redis.instance_method(meth).arity.zero?
|
82
|
+
client.send(meth, &block)
|
83
|
+
else
|
84
|
+
client.send(meth, self, *args, &block)
|
85
|
+
end
|
81
86
|
end
|
82
87
|
end
|
83
88
|
|
84
89
|
SLAVE_METHODS.each do |meth|
|
85
90
|
define_method(meth) do |*args, &block|
|
86
|
-
|
91
|
+
client = current || slave
|
92
|
+
if Redis.instance_method(meth).arity.zero?
|
93
|
+
client.send(meth, &block)
|
94
|
+
else
|
95
|
+
client.send(meth, self, *args, &block)
|
96
|
+
end
|
87
97
|
end
|
88
98
|
end
|
89
99
|
|
data/lib/redpear/persistence.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: redpear
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2011-12-24 00:00:00.000000000Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: redis
|
16
|
-
requirement: &
|
16
|
+
requirement: &25862360 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 2.2.0
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *25862360
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: rake
|
27
|
-
requirement: &
|
27
|
+
requirement: &25894420 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *25894420
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: bundler
|
38
|
-
requirement: &
|
38
|
+
requirement: &25893960 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *25893960
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: rspec
|
49
|
-
requirement: &
|
49
|
+
requirement: &25893540 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *25893540
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: fakeredis
|
60
|
-
requirement: &
|
60
|
+
requirement: &25893120 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ! '>='
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: '0'
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *25893120
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: shoulda-matchers
|
71
|
-
requirement: &
|
71
|
+
requirement: &25892700 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ! '>='
|
@@ -76,7 +76,7 @@ dependencies:
|
|
76
76
|
version: '0'
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *25892700
|
80
80
|
description: Simple, elegant & efficient ORM for Redis
|
81
81
|
email: dimitrij@blacksquaremedia.com
|
82
82
|
executables: []
|