mimeo 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/README.md +18 -1
  2. data/lib/mimeo/version.rb +1 -1
  3. data/lib/mimeo.rb +1 -1
  4. metadata +2 -2
data/README.md CHANGED
@@ -1,11 +1,14 @@
1
1
  # Mimeo
2
2
 
3
- This lets you easily call your Ohm model's save from within your Rails models after_save.
3
+ This is a gem to let you easily access your Ohm models from within your Rails models after_save.
4
4
 
5
5
  It creates an after_save callback insider your ActiveRecord model. The callback finds the matching Redis record and updates it with the content of the AR instance.
6
6
  If a matching record is not found, a new one is created and saved.
7
7
 
8
8
  All accessible attributes (attr_accessible) are used to populate the Redis record. There should be a one-to-one correspondence between the Rails and the Redis attribute names.
9
+ If :field_map is specified in the options, then only those in the field_map hash are used to populate the Redis record.
10
+
11
+ It also adds an ohm_instance convenience method into the ActiveRecord instance.
9
12
 
10
13
  ## Installation
11
14
 
@@ -29,11 +32,25 @@ Inside your ActiveRecord model, add:
29
32
 
30
33
  where ModelName is the name of your Ohm model.
31
34
 
35
+ If you want to customize the field mapping:
36
+
37
+ ohm_model <ModelName>,
38
+ field_map: {
39
+ active_record_attr1: :ohm_model_attr1,
40
+ active_record_attr2: :ohm_model_attr2
41
+ ...
42
+ }
43
+
32
44
  Inside your Ohm model, add:
33
45
 
34
46
  attribute :rails_id, Type::Integer
35
47
  index :rails_id
36
48
 
49
+ Once setup, your ActiveRecord model instances have access to the corresponding Ohm record, like so:
50
+
51
+ user = User.find(1)
52
+ puts user.ohm_instance.ohm_instance_attribute
53
+
37
54
  ## Contributing
38
55
 
39
56
  1. Fork it
data/lib/mimeo/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Mimeo
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
data/lib/mimeo.rb CHANGED
@@ -32,7 +32,7 @@ module Mimeo
32
32
  return true
33
33
  end
34
34
 
35
- def get_redis_record
35
+ def ohm_instance
36
36
  ohm_model_class.find(rails_id: self.id).first || ohm_model_class.new
37
37
  end
38
38
 
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.5
4
+ version: 0.0.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-09-13 00:00:00.000000000 Z
12
+ date: 2012-09-18 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: ActiveRecord extension for saving data to Redis using a given Ohm model.
15
15
  email: