mimeo 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/lib/mimeo/version.rb +1 -1
  2. data/lib/mimeo.rb +13 -4
  3. metadata +1 -1
data/lib/mimeo/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Mimeo
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
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(ohm_model_class, ohm_model_index)
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(model, index)
26
- model.find(rails_id: self.id).first || model.new
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)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mimeo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: