perpetuity-memory 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/perpetuity/memory.rb +4 -4
- data/lib/perpetuity/memory/version.rb +1 -1
- data/spec/perpetuity/memory_spec.rb +3 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ca9f272273107e89f3ecac8937d20ccf945707e9
|
4
|
+
data.tar.gz: c74fd2ac60046eeaf97b8ffe523010da30616e86
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e31010b928e5ba96b9f4c6e4df201c78742fb5b66f0a6926588fb0a8149cd62aa663b1ba380c23abc356763c2b0bb27d575178babc8fabf5eec7589c415ac7cc
|
7
|
+
data.tar.gz: 16d030e599d7e18f149e6a818c64ed82fa356e2feb1ed0ff4b352a04f0c9d5d3a8ad781503728c5bdc2c290df666028e889fd4ad34f3d09c7a68b3add67135c0
|
data/lib/perpetuity/memory.rb
CHANGED
@@ -8,7 +8,7 @@ module Perpetuity
|
|
8
8
|
class Memory
|
9
9
|
def initialize options = {}
|
10
10
|
@cache = Hash.new
|
11
|
-
@indexes = Hash.new
|
11
|
+
@indexes = Hash.new
|
12
12
|
end
|
13
13
|
|
14
14
|
def insert klass, attributes, _
|
@@ -99,15 +99,15 @@ module Perpetuity
|
|
99
99
|
|
100
100
|
|
101
101
|
def index klass, attribute, options={}
|
102
|
-
|
102
|
+
indexes(klass) << attribute
|
103
103
|
end
|
104
104
|
|
105
105
|
def indexes klass
|
106
|
-
@indexes[klass]
|
106
|
+
@indexes[klass] ||= Set.new
|
107
107
|
end
|
108
108
|
|
109
109
|
def active_indexes klass
|
110
|
-
|
110
|
+
indexes(klass)
|
111
111
|
end
|
112
112
|
|
113
113
|
def activate_index! klass
|
@@ -60,8 +60,9 @@ module Perpetuity
|
|
60
60
|
end
|
61
61
|
|
62
62
|
describe 'indexing' do
|
63
|
-
it '
|
64
|
-
subject.index(klass, '
|
63
|
+
it 'keeps track of what attributes were indexed' do
|
64
|
+
subject.index(klass, Perpetuity::Attribute.new('name'))
|
65
|
+
subject.indexes(klass).map{|a| a.name}.should include('name')
|
65
66
|
end
|
66
67
|
end
|
67
68
|
|