mimeo 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/mimeo/version.rb +1 -1
- data/lib/mimeo.rb +13 -4
- metadata +1 -1
data/lib/mimeo/version.rb
CHANGED
data/lib/mimeo.rb
CHANGED
@@ -6,24 +6,33 @@ module Mimeo
|
|
6
6
|
cattr_accessor :ohm_model_class, :ohm_model_index
|
7
7
|
|
8
8
|
self.ohm_model_class = model
|
9
|
-
self.ohm_model_index = options[:index]
|
10
9
|
|
11
10
|
self.set_callback :save, :after do
|
12
11
|
self.save_to_redis
|
13
12
|
end
|
13
|
+
|
14
|
+
self.set_callback :destroy, :after do
|
15
|
+
self.remove_from_redis
|
16
|
+
end
|
14
17
|
end
|
15
18
|
end
|
16
19
|
|
17
20
|
module InstanceMethods
|
21
|
+
def remove_from_redis
|
22
|
+
redis_record = get_redis_record
|
23
|
+
redis_record.delete
|
24
|
+
return true
|
25
|
+
end
|
26
|
+
|
18
27
|
def save_to_redis
|
19
|
-
redis_record = get_redis_record
|
28
|
+
redis_record = get_redis_record
|
20
29
|
populate redis_record
|
21
30
|
redis_record.save
|
22
31
|
return true
|
23
32
|
end
|
24
33
|
|
25
|
-
def get_redis_record
|
26
|
-
|
34
|
+
def get_redis_record
|
35
|
+
ohm_model_class.find(rails_id: self.id).first || ohm_model_class.new
|
27
36
|
end
|
28
37
|
|
29
38
|
def populate(record)
|