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
- if @callback
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
- if @callback
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
@@ -1,3 +1,3 @@
1
1
  module MongoidSilo
2
- VERSION = "0.3.1"
2
+ VERSION = "0.3.2"
3
3
  end
@@ -172,7 +172,7 @@ describe Silo do
172
172
  end
173
173
  end
174
174
 
175
- context "Callbacks", focus: true do
175
+ context "Callbacks" do
176
176
  subject(:project) { build(:callback_project) }
177
177
 
178
178
  it "should trigger a named callback" do
@@ -8,13 +8,11 @@ class CallbackProject
8
8
  config.callback = :triggered
9
9
  end
10
10
 
11
- def triggered
12
- Proc.new{|x|
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongoid_silo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: