mimeo 0.0.2 → 0.0.3
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 +6 -4
- metadata +1 -1
data/lib/mimeo/version.rb
CHANGED
data/lib/mimeo.rb
CHANGED
@@ -2,10 +2,11 @@ require "mimeo/version"
|
|
2
2
|
|
3
3
|
module Mimeo
|
4
4
|
module ClassMethods
|
5
|
-
def ohm_model(model,
|
5
|
+
def ohm_model(model, field_map)
|
6
6
|
cattr_accessor :ohm_model_class, :ohm_model_index
|
7
7
|
|
8
8
|
self.ohm_model_class = model
|
9
|
+
self.field_map = field_map
|
9
10
|
|
10
11
|
self.set_callback :save, :after do
|
11
12
|
self.save_to_redis
|
@@ -36,9 +37,10 @@ module Mimeo
|
|
36
37
|
end
|
37
38
|
|
38
39
|
def populate(record)
|
39
|
-
self.class.accessible_attributes.to_a.reject{|a| a.blank?}.map{|a| a.to_sym}.each do |attr|
|
40
|
-
|
41
|
-
|
40
|
+
# self.class.accessible_attributes.to_a.reject{|a| a.blank?}.map{|a| a.to_sym}.each do |attr|
|
41
|
+
field_map.each do |rails_field, ohm_field|
|
42
|
+
val = self.send(rails_field)
|
43
|
+
record.send("#{ohm_field}=", val)
|
42
44
|
record.rails_id = self.id
|
43
45
|
end
|
44
46
|
end
|