mimeo 0.0.5 → 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +18 -1
- data/lib/mimeo/version.rb +1 -1
- data/lib/mimeo.rb +1 -1
- metadata +2 -2
data/README.md
CHANGED
@@ -1,11 +1,14 @@
|
|
1
1
|
# Mimeo
|
2
2
|
|
3
|
-
This
|
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
data/lib/mimeo.rb
CHANGED
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.
|
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-
|
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:
|