mongoid_silo 0.3.1 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
@@ -21,7 +21,7 @@ module MongoidSilo
|
|
21
21
|
else
|
22
22
|
@silo = Silo.create(item_class: @item_class, item_id: @item_id, bag: @content, silo_type: name)
|
23
23
|
end
|
24
|
-
|
24
|
+
unless @callback.nil? || @callback == ""
|
25
25
|
@item.__send__(@callback, :updated)
|
26
26
|
end
|
27
27
|
end
|
@@ -31,7 +31,7 @@ module MongoidSilo
|
|
31
31
|
if @silo
|
32
32
|
@silo.destroy
|
33
33
|
end
|
34
|
-
|
34
|
+
unless @callback.nil? || @callback == ""
|
35
35
|
@item.__send__(@callback, :destroyed)
|
36
36
|
end
|
37
37
|
end
|
data/lib/mongoid/silo.rb
CHANGED
@@ -59,12 +59,12 @@ module Mongoid
|
|
59
59
|
key[:class_name].classify.constantize.class_eval <<-EOS, __FILE__, __LINE__+1
|
60
60
|
set_callback :save, :after do
|
61
61
|
ident = key[:foreign_key].to_sym
|
62
|
-
MongoidSilo::UpdateSiloWorker.perform_async(self.__send__(ident), "#{key[:parent_class]}", "#{key[:silo_name]}", :save, "#{key[:generator]}", #{key[:callback]})
|
62
|
+
MongoidSilo::UpdateSiloWorker.perform_async(self.__send__(ident), "#{key[:parent_class]}", "#{key[:silo_name]}", :save, "#{key[:generator]}", "#{key[:callback]}")
|
63
63
|
end
|
64
64
|
|
65
65
|
set_callback :destroy, :after do
|
66
66
|
ident = key[:foreign_key].to_sym
|
67
|
-
MongoidSilo::UpdateSiloWorker.perform_async(self.__send__(ident), "#{key[:parent_class]}", "#{key[:silo_name]}", :destroy, #{key[:callback]})
|
67
|
+
MongoidSilo::UpdateSiloWorker.perform_async(self.__send__(ident), "#{key[:parent_class]}", "#{key[:silo_name]}", :destroy, "#{key[:callback]}")
|
68
68
|
end
|
69
69
|
EOS
|
70
70
|
end
|
data/lib/mongoid_silo/version.rb
CHANGED
data/spec/models/silo_spec.rb
CHANGED
@@ -8,13 +8,11 @@ class CallbackProject
|
|
8
8
|
config.callback = :triggered
|
9
9
|
end
|
10
10
|
|
11
|
-
def triggered
|
12
|
-
|
13
|
-
x.class.triggered
|
14
|
-
}
|
11
|
+
def triggered context
|
12
|
+
self.class.triggered
|
15
13
|
end
|
16
14
|
|
17
|
-
def self.triggered
|
15
|
+
def self.triggered
|
18
16
|
true
|
19
17
|
end
|
20
18
|
end
|