promiscuous 0.14.0 → 0.15.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -5,7 +5,7 @@ module Promiscuous::Publisher::Class
5
5
  included { use_option :class, :as => :klass }
6
6
 
7
7
  module ClassMethods
8
- def setup_binding
8
+ def setup_class_binding
9
9
  publisher_class = self
10
10
  klass.class_eval do
11
11
  class_attribute :promiscuous_publisher
@@ -13,14 +13,19 @@ module Promiscuous::Publisher::Class
13
13
  end if klass
14
14
  end
15
15
 
16
+ def self.publish(options)
17
+ super
18
+ setup_class_binding
19
+ end
20
+
16
21
  def inherited(subclass)
17
22
  super
18
- subclass.setup_binding unless options[:class]
23
+ subclass.setup_class_binding unless options[:class]
19
24
  end
20
25
 
21
26
  def klass=(value)
22
27
  super
23
- setup_binding
28
+ setup_class_binding
24
29
  end
25
30
 
26
31
  def klass
@@ -14,17 +14,9 @@ module Promiscuous::Publisher::Model
14
14
  operation != :destroy
15
15
  end
16
16
 
17
- included do
18
- hook_callbacks if published
19
- end
20
-
21
17
  module ClassMethods
22
- def publish(options)
18
+ def setup_class_binding
23
19
  super
24
- hook_callbacks
25
- end
26
-
27
- def hook_callbacks
28
20
  klass.class_eval do
29
21
  cattr_accessor :publisher_operation_hooked
30
22
  return if self.publisher_operation_hooked
@@ -42,7 +34,7 @@ module Promiscuous::Publisher::Model
42
34
  self.class.promiscuous_publisher.new(options).publish
43
35
  true
44
36
  end
45
- end
37
+ end if klass
46
38
  end
47
39
  end
48
40
  end
@@ -42,20 +42,23 @@ module Promiscuous::Publisher::Mongoid::Defer
42
42
  end
43
43
  end
44
44
 
45
- included do
46
- klass.class_eval do
47
- cattr_accessor :publisher_defer_hooked
48
- return if self.publisher_defer_hooked
49
- self.publisher_defer_hooked = true
50
-
51
- # TODO Make sure we are not overriding a field, although VERY unlikly
52
- field :_psp, :type => Boolean
53
- field :_psv, :type => Integer
54
- index({:_psp => 1}, :background => true, :sparse => true)
55
-
56
- Promiscuous::Publisher::Mongoid::Defer.hook_mongoid
57
- Promiscuous::Publisher::Mongoid::Defer.klasses[self.to_s] = self
58
- Promiscuous::Publisher::Mongoid::Defer.collections[collection.name] = true
45
+ module ClassMethods
46
+ def setup_class_binding
47
+ super
48
+ klass.class_eval do
49
+ cattr_accessor :publisher_defer_hooked
50
+ return if self.publisher_defer_hooked
51
+ self.publisher_defer_hooked = true
52
+
53
+ # TODO Make sure we are not overriding a field, although VERY unlikly
54
+ field :_psp, :type => Boolean
55
+ field :_psv, :type => Integer
56
+ index({:_psp => 1}, :background => true, :sparse => true)
57
+
58
+ Promiscuous::Publisher::Mongoid::Defer.hook_mongoid
59
+ Promiscuous::Publisher::Mongoid::Defer.klasses[self.to_s] = self
60
+ Promiscuous::Publisher::Mongoid::Defer.collections[collection.name] = true
61
+ end if klass
59
62
  end
60
63
  end
61
64
  end
@@ -22,6 +22,8 @@ class Promiscuous::Publisher::Mongoid < Promiscuous::Publisher::Base
22
22
  include Promiscuous::Publisher::Model
23
23
  include Promiscuous::Publisher::Mongoid::Defer if mongoid3?
24
24
  end
25
+
26
+ setup_class_binding
25
27
  end
26
28
 
27
29
  def self.mongoid3?
@@ -9,6 +9,18 @@ module Promiscuous::Subscriber::Class
9
9
  included { use_option :class, :as => :klass }
10
10
 
11
11
  module ClassMethods
12
+ def setup_class_binding; end
13
+
14
+ def self.subscribe(options)
15
+ super
16
+ setup_class_binding
17
+ end
18
+
19
+ def klass=(value)
20
+ super
21
+ setup_class_binding
22
+ end
23
+
12
24
  def klass
13
25
  return nil if name.nil?
14
26
  "::#{super ? super : guess_class_name('Subscribers')}".constantize
@@ -29,8 +29,12 @@ module Promiscuous::Subscriber::Mongoid::Versioning
29
29
  instance.use_atomic_promiscuous_selector = false
30
30
  end
31
31
 
32
- included do
33
- klass.__send__(:include, AtomicSelector)
34
- use_payload_attribute :version
32
+ included { use_payload_attribute :version }
33
+
34
+ module ClassMethods
35
+ def setup_class_binding
36
+ super
37
+ klass.__send__(:include, AtomicSelector) if klass
38
+ end
35
39
  end
36
40
  end
@@ -22,5 +22,7 @@ class Promiscuous::Subscriber::Mongoid < Promiscuous::Subscriber::Base
22
22
  include Promiscuous::Subscriber::Upsert
23
23
  include Promiscuous::Subscriber::Mongoid::Versioning
24
24
  end
25
+
26
+ setup_class_binding
25
27
  end
26
28
  end
@@ -1,3 +1,3 @@
1
1
  module Promiscuous
2
- VERSION = '0.14.0'
2
+ VERSION = '0.15.0'
3
3
  end
data/lib/promiscuous.rb CHANGED
@@ -22,5 +22,12 @@ module Promiscuous
22
22
  Promiscuous::Config.logger.__send__(level, "[promiscuous] #{msg}")
23
23
  end
24
24
  end
25
+
26
+ def reload
27
+ desc = Promiscuous::Publisher::Base.descendants
28
+ desc += Promiscuous::Subscriber::Base.descendants
29
+ desc.reject! { |klass| klass.name =~ /^Promiscuous::/ }
30
+ desc.each { |klass| klass.setup_class_binding }
31
+ end
25
32
  end
26
33
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: promiscuous
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.14.0
4
+ version: 0.15.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-11-28 00:00:00.000000000 Z
13
+ date: 2012-11-29 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activesupport
@@ -116,37 +116,41 @@ executables: []
116
116
  extensions: []
117
117
  extra_rdoc_files: []
118
118
  files:
119
- - lib/promiscuous/amqp/null.rb
120
119
  - lib/promiscuous/amqp/bunny.rb
120
+ - lib/promiscuous/amqp/null.rb
121
121
  - lib/promiscuous/amqp/rubyamqp.rb
122
+ - lib/promiscuous/common.rb
123
+ - lib/promiscuous/common/class_helpers.rb
122
124
  - lib/promiscuous/common/lint.rb
123
125
  - lib/promiscuous/common/lint/base.rb
124
126
  - lib/promiscuous/common/options.rb
125
- - lib/promiscuous/common/class_helpers.rb
126
127
  - lib/promiscuous/common/worker.rb
128
+ - lib/promiscuous/config.rb
127
129
  - lib/promiscuous/loader.rb
130
+ - lib/promiscuous/observer.rb
131
+ - lib/promiscuous/publisher.rb
128
132
  - lib/promiscuous/publisher/active_record.rb
129
- - lib/promiscuous/publisher/base.rb
130
133
  - lib/promiscuous/publisher/envelope.rb
134
+ - lib/promiscuous/publisher/ephemeral.rb
135
+ - lib/promiscuous/publisher/error.rb
131
136
  - lib/promiscuous/publisher/lint.rb
132
137
  - lib/promiscuous/publisher/lint/amqp.rb
133
138
  - lib/promiscuous/publisher/lint/attributes.rb
134
139
  - lib/promiscuous/publisher/lint/base.rb
135
140
  - lib/promiscuous/publisher/lint/class.rb
136
141
  - lib/promiscuous/publisher/lint/polymorphic.rb
142
+ - lib/promiscuous/publisher/mock.rb
137
143
  - lib/promiscuous/publisher/mongoid/embedded.rb
138
144
  - lib/promiscuous/publisher/mongoid/defer_embedded.rb
139
145
  - lib/promiscuous/publisher/mongoid/embedded_many.rb
140
146
  - lib/promiscuous/publisher/mongoid/defer.rb
141
147
  - lib/promiscuous/publisher/polymorphic.rb
142
- - lib/promiscuous/publisher/class.rb
143
- - lib/promiscuous/publisher/mock.rb
144
- - lib/promiscuous/publisher/error.rb
145
- - lib/promiscuous/publisher/ephemeral.rb
146
148
  - lib/promiscuous/publisher/attributes.rb
147
- - lib/promiscuous/publisher/mongoid.rb
148
149
  - lib/promiscuous/publisher/amqp.rb
149
150
  - lib/promiscuous/publisher/worker.rb
151
+ - lib/promiscuous/publisher/base.rb
152
+ - lib/promiscuous/publisher/mongoid.rb
153
+ - lib/promiscuous/publisher/class.rb
150
154
  - lib/promiscuous/publisher/model.rb
151
155
  - lib/promiscuous/railtie.rb
152
156
  - lib/promiscuous/railtie/replicate.rake
@@ -155,31 +159,27 @@ files:
155
159
  - lib/promiscuous/subscriber/error.rb
156
160
  - lib/promiscuous/subscriber/lint.rb
157
161
  - lib/promiscuous/subscriber/lint/amqp.rb
162
+ - lib/promiscuous/subscriber/lint/attributes.rb
158
163
  - lib/promiscuous/subscriber/lint/base.rb
159
164
  - lib/promiscuous/subscriber/lint/class.rb
160
165
  - lib/promiscuous/subscriber/lint/polymorphic.rb
161
- - lib/promiscuous/subscriber/lint/attributes.rb
162
- - lib/promiscuous/subscriber/mongoid/embedded_many.rb
163
166
  - lib/promiscuous/subscriber/mongoid/embedded.rb
167
+ - lib/promiscuous/subscriber/mongoid/embedded_many.rb
164
168
  - lib/promiscuous/subscriber/mongoid/versioning.rb
165
- - lib/promiscuous/subscriber/upsert.rb
166
- - lib/promiscuous/subscriber/class.rb
167
169
  - lib/promiscuous/subscriber/observer.rb
168
170
  - lib/promiscuous/subscriber/polymorphic.rb
171
+ - lib/promiscuous/subscriber/upsert.rb
169
172
  - lib/promiscuous/subscriber/amqp.rb
173
+ - lib/promiscuous/subscriber/attributes.rb
170
174
  - lib/promiscuous/subscriber/base.rb
171
175
  - lib/promiscuous/subscriber/worker.rb
172
- - lib/promiscuous/subscriber/attributes.rb
173
176
  - lib/promiscuous/subscriber/model.rb
177
+ - lib/promiscuous/subscriber/class.rb
174
178
  - lib/promiscuous/subscriber/mongoid.rb
175
- - lib/promiscuous/observer.rb
176
- - lib/promiscuous/common.rb
177
- - lib/promiscuous/publisher.rb
178
- - lib/promiscuous/config.rb
179
+ - lib/promiscuous/subscriber.rb
180
+ - lib/promiscuous/ephemeral.rb
179
181
  - lib/promiscuous/amqp.rb
180
182
  - lib/promiscuous/worker.rb
181
- - lib/promiscuous/ephemeral.rb
182
- - lib/promiscuous/subscriber.rb
183
183
  - lib/promiscuous/version.rb
184
184
  - lib/promiscuous.rb
185
185
  - README.md