association_observers 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/.travis.yml +1 -0
- data/Gemfile +6 -0
- data/README.md +57 -2
- data/Rakefile +18 -0
- data/association_observers.gemspec +3 -3
- data/lib/association_observers.rb +43 -31
- data/lib/association_observers/{activerecord.rb → active_record.rb} +15 -16
- data/lib/association_observers/{datamapper.rb → data_mapper.rb} +11 -20
- data/lib/association_observers/extensions/delayed_job.rb +13 -0
- data/lib/association_observers/extensions/resque.rb +30 -0
- data/lib/association_observers/extensions/sidekiq.rb +32 -0
- data/lib/association_observers/notifiers/base.rb +46 -21
- data/lib/association_observers/notifiers/propagation_notifier.rb +2 -2
- data/lib/association_observers/orm/active_record.rb +48 -0
- data/lib/association_observers/orm/base.rb +61 -0
- data/lib/association_observers/orm/data_mapper.rb +61 -0
- data/lib/association_observers/queue.rb +71 -0
- data/lib/association_observers/railtie.rb +11 -4
- data/lib/association_observers/ruby18.rb +26 -8
- data/lib/association_observers/version.rb +1 -1
- data/lib/association_observers/workers/many_delayed_notification.rb +41 -0
- data/spec/activerecord/association_observers_spec.rb +32 -1
- data/spec/activerecord/delayed_job/association_observers_spec.rb +8 -0
- data/spec/activerecord/readme_example_spec.rb +1 -1
- data/spec/activerecord/resque/association_observers_spec.rb +8 -0
- data/spec/activerecord/sidekiq/association_observers_spec.rb +8 -0
- data/spec/datamapper/association_observers_spec.rb +37 -2
- data/spec/{active_record_helper.rb → helpers/active_record_helper.rb} +4 -1
- data/spec/{datamapper_helper.rb → helpers/datamapper_helper.rb} +1 -1
- data/spec/helpers/delayed_job_helper.rb +26 -0
- data/spec/helpers/resque_helper.rb +5 -0
- data/spec/helpers/sidekiq_helper.rb +4 -0
- metadata +174 -156
@@ -1,12 +1,30 @@
|
|
1
1
|
# -*- encoding : utf-8 -*-
|
2
2
|
module AssociationObservers
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
3
|
+
module Backports
|
4
|
+
def self.extended_to_s(val)
|
5
|
+
if val.is_a?(Hash)
|
6
|
+
"{#{val.map{|k, v| ":#{k}=>#{extended_to_s(v)}"}.join(",")}}"
|
7
|
+
elsif val.is_a?(Array)
|
8
|
+
"[#{val.map{|a|extended_to_s(a)}.join(",")}]"
|
9
|
+
else
|
10
|
+
val.is_a?(Symbol) ? ":#{val}" : val.is_a?(String) ? "\"#{val}\"" : val
|
11
|
+
end
|
10
12
|
end
|
13
|
+
|
14
|
+
|
15
|
+
def self.hash_select(hash, &proc)
|
16
|
+
Hash[hash.select(&proc)]
|
17
|
+
end
|
18
|
+
|
19
|
+
module Proc
|
20
|
+
# it's called fake curry because it only works on one level, that is, you can only pass one level of sub-arguments
|
21
|
+
# sorry, ruby 1.8 sucks balls
|
22
|
+
def self.fake_curry(method, *args)
|
23
|
+
proc { |*proc_args|
|
24
|
+
method.call(*(args + proc_args))
|
25
|
+
}
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
11
29
|
end
|
12
|
-
end
|
30
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
module AssociationObservers
|
3
|
+
module Workers
|
4
|
+
# This is our main batched worker. It helps on the task of queueing batches of records and asynchronously
|
5
|
+
# call the notifier conditional action for each of them.
|
6
|
+
class ManyDelayedNotification
|
7
|
+
|
8
|
+
attr_reader :observer_ids, :observer_klass, :observable_id, :observable_klass, :notifier
|
9
|
+
|
10
|
+
# @param [Array] observer_ids array of ids of the observers which are going to be iterated
|
11
|
+
# @param [String] observer_klass the class of the observers
|
12
|
+
# @param [Integer, String] observable_id if of the observable
|
13
|
+
# @param [String] observable_klass the class of the observable
|
14
|
+
# @param [String] notifier the notifier containing the action in marshalled format
|
15
|
+
def initialize(observer_ids, observer_klass, observable_id, observable_klass, notifier)
|
16
|
+
@observer_ids = observer_ids
|
17
|
+
@observer_klass = observer_klass
|
18
|
+
@observable_id = observable_id
|
19
|
+
@observable_klass = observable_klass
|
20
|
+
@notifier = Marshal.dump(notifier)
|
21
|
+
end
|
22
|
+
|
23
|
+
# Here we execute our task:
|
24
|
+
# 1. Unmarshal notifier, get observable
|
25
|
+
# 2. Load all the observers
|
26
|
+
# 3. Iterate over them and execute the notifier #conditional_action, which takes the observer and the observable as parameters
|
27
|
+
def perform
|
28
|
+
observable = AssociationObservers::orm_adapter.find(@observable_klass.constantize, @observable_id)
|
29
|
+
return if observable.nil?
|
30
|
+
notifier = Marshal.load(@notifier)
|
31
|
+
method = RUBY_VERSION < "1.9" ?
|
32
|
+
AssociationObservers::Backports::Proc.fake_curry(notifier.method(:conditional_action).to_proc, observable) :
|
33
|
+
notifier.method(:conditional_action).to_proc.curry[observable]
|
34
|
+
AssociationObservers::orm_adapter.find_all(@observer_klass.constantize, :id => @observer_ids).each(&method)
|
35
|
+
end
|
36
|
+
|
37
|
+
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# -*- encoding : utf-8 -*-
|
2
|
-
require "./spec/active_record_helper"
|
2
|
+
require "./spec/helpers/active_record_helper"
|
3
3
|
require "./spec/spec_helper"
|
4
4
|
|
5
5
|
|
@@ -90,6 +90,7 @@ describe AssociationObservers do
|
|
90
90
|
has_many :polymorphic_has_many_observable_tests, :as => :observer
|
91
91
|
|
92
92
|
has_one :observer_observer_test
|
93
|
+
has_many :many_observer_observer_tests
|
93
94
|
|
94
95
|
has_and_belongs_to_many :habtm_observable_tests
|
95
96
|
|
@@ -126,6 +127,13 @@ describe AssociationObservers do
|
|
126
127
|
observes :observer_test, :notifiers => :test_update, :on => :update
|
127
128
|
end
|
128
129
|
|
130
|
+
class ManyObserverObserverTest < ObserverAbstractTest
|
131
|
+
belongs_to :observer_test
|
132
|
+
attr_accessible :observer_test
|
133
|
+
|
134
|
+
observes :observer_test, :notifiers => :test_update, :on => :update
|
135
|
+
end
|
136
|
+
|
129
137
|
ActiveRecord::Schema.define do
|
130
138
|
create_table :association_observer_tests, :force => true do |t|
|
131
139
|
t.column :type, :string # for polymorphic test only
|
@@ -428,6 +436,29 @@ describe AssociationObservers do
|
|
428
436
|
end
|
429
437
|
end
|
430
438
|
|
439
|
+
describe "when the observer has an observer collection itself" do
|
440
|
+
before(:each) do
|
441
|
+
observer1.update_attribute(:many_observer_observer_tests, [ManyObserverObserverTest.new,
|
442
|
+
ManyObserverObserverTest.new,
|
443
|
+
ManyObserverObserverTest.new])
|
444
|
+
observer1.reload
|
445
|
+
end
|
446
|
+
describe "and the batch size for the observer observers has changed" do
|
447
|
+
before do
|
448
|
+
@old_batch_size = ObserverTest.observable_options[:batch_size]
|
449
|
+
ManyObserverObserverTest.stub! :observable? => true
|
450
|
+
ObserverTest.batch_size = 101
|
451
|
+
end
|
452
|
+
after do
|
453
|
+
ObserverTest.batch_size = @old_batch_size
|
454
|
+
end
|
455
|
+
it "should update the observer observers collection with the right batch size" do
|
456
|
+
AssociationObservers.should_receive(:batched_each).with(anything, 101).any_number_of_times
|
457
|
+
belongs_to_observable.update_attributes(:name => "doof")
|
458
|
+
end
|
459
|
+
end
|
460
|
+
end
|
461
|
+
|
431
462
|
|
432
463
|
describe "when the association is polymorphic" do
|
433
464
|
class HasOnePolymorphicObservableTest < ObservableAbstractTest
|
@@ -0,0 +1,8 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
require "./spec/helpers/active_record_helper"
|
3
|
+
require "./spec/helpers/delayed_job_helper"
|
4
|
+
require "./spec/spec_helper"
|
5
|
+
|
6
|
+
AssociationObservers::queue.engine = :delayed_job
|
7
|
+
|
8
|
+
eval File.read(File.join(File.dirname(__FILE__), '..', 'association_observers_spec.rb'))
|
@@ -0,0 +1,8 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
require "./spec/helpers/active_record_helper"
|
3
|
+
require "./spec/helpers/resque_helper"
|
4
|
+
require "./spec/spec_helper"
|
5
|
+
|
6
|
+
AssociationObservers::queue.engine = :resque
|
7
|
+
|
8
|
+
eval File.read(File.join(File.dirname(__FILE__), '..', 'association_observers_spec.rb'))
|
@@ -0,0 +1,8 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
require "./spec/helpers/active_record_helper"
|
3
|
+
require "./spec/helpers/sidekiq_helper"
|
4
|
+
require "./spec/spec_helper"
|
5
|
+
|
6
|
+
AssociationObservers::queue.engine = :sidekiq
|
7
|
+
|
8
|
+
eval File.read(File.join(File.dirname(__FILE__), '..', 'association_observers_spec.rb'))
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# -*- encoding : utf-8 -*-
|
2
|
-
require "./spec/datamapper_helper"
|
2
|
+
require "./spec/helpers/datamapper_helper"
|
3
3
|
require "./spec/spec_helper"
|
4
4
|
|
5
5
|
|
@@ -109,6 +109,7 @@ describe AssociationObservers do
|
|
109
109
|
|
110
110
|
|
111
111
|
has 1, :observer_observer_test
|
112
|
+
has n, :many_observer_observer_tests
|
112
113
|
|
113
114
|
has n, :habtm_observable_tests, :through => Resource
|
114
115
|
|
@@ -141,6 +142,19 @@ describe AssociationObservers do
|
|
141
142
|
observes :observer_test, :notifiers => :test_update, :on => :update
|
142
143
|
end
|
143
144
|
|
145
|
+
class ManyObserverObserverTest
|
146
|
+
include DataMapper::Resource
|
147
|
+
|
148
|
+
property :id, Serial
|
149
|
+
property :type, Discriminator
|
150
|
+
property :updated, Boolean
|
151
|
+
property :deleted, Boolean
|
152
|
+
|
153
|
+
belongs_to :observer_test, :required => false
|
154
|
+
|
155
|
+
observes :observer_test, :notifiers => :test_update, :on => :update
|
156
|
+
end
|
157
|
+
|
144
158
|
DataMapper.finalize
|
145
159
|
|
146
160
|
DataMapper.auto_migrate!
|
@@ -177,7 +191,6 @@ describe AssociationObservers do
|
|
177
191
|
observer1.should_not be_deleted
|
178
192
|
end
|
179
193
|
end
|
180
|
-
|
181
194
|
describe "when the belongs to observable is updated" do
|
182
195
|
before(:each) do
|
183
196
|
belongs_to_observable.update(:name => "doof")
|
@@ -322,6 +335,28 @@ describe AssociationObservers do
|
|
322
335
|
end
|
323
336
|
end
|
324
337
|
|
338
|
+
describe "when the observer has an observer collection itself" do
|
339
|
+
before(:each) do
|
340
|
+
ManyObserverObserverTest.create(:observer_test => observer1)
|
341
|
+
observer1.reload
|
342
|
+
end
|
343
|
+
describe "and the batch size for the observer observers has changed" do
|
344
|
+
before do
|
345
|
+
@old_batch_size = ObserverTest.observable_options[:batch_size]
|
346
|
+
ManyObserverObserverTest.stub! :observable? => true
|
347
|
+
ManyObserverObserverTest.any_instance.stub :notify_observers => true
|
348
|
+
ObserverTest.batch_size = 101
|
349
|
+
end
|
350
|
+
after do
|
351
|
+
ObserverTest.batch_size = @old_batch_size
|
352
|
+
end
|
353
|
+
it "should update the observer observers collection with the right batch size" do
|
354
|
+
AssociationObservers.should_receive(:batched_each).with(anything, 101).any_number_of_times
|
355
|
+
belongs_to_observable.update(:name => "doof")
|
356
|
+
end
|
357
|
+
end
|
358
|
+
end
|
359
|
+
|
325
360
|
describe "when the association is a joined through" do
|
326
361
|
class HasOneThroughObservableTest
|
327
362
|
include DataMapper::Resource
|
@@ -1,5 +1,8 @@
|
|
1
1
|
# -*- encoding : utf-8 -*-
|
2
2
|
require 'rubygems'
|
3
3
|
require 'active_record'
|
4
|
-
|
4
|
+
require 'logger'
|
5
|
+
ActiveRecord::Base.configurations = YAML.load_file(File.join(File.expand_path('../../..', __FILE__), 'database.yml'))
|
5
6
|
ActiveRecord::Base.establish_connection("activerecord")
|
7
|
+
FileUtils.mkdir_p("log")
|
8
|
+
ActiveRecord::Base.logger = Logger.new(File.new("log/test.log", "w"))
|
@@ -2,6 +2,6 @@
|
|
2
2
|
require 'rubygems'
|
3
3
|
require 'data_mapper'
|
4
4
|
|
5
|
-
datamapper_config = YAML.load_file(File.join(File.expand_path('
|
5
|
+
datamapper_config = YAML.load_file(File.join(File.expand_path('../../..', __FILE__), 'database.yml'))["datamapper"]
|
6
6
|
|
7
7
|
DataMapper.setup(:default, datamapper_config)
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
require "logger"
|
3
|
+
require "delayed_job_active_record"
|
4
|
+
|
5
|
+
FileUtils.mkdir_p("log")
|
6
|
+
Delayed::Worker.logger = Logger.new(File.new("log/delayed.log", "w"))
|
7
|
+
|
8
|
+
Delayed::Worker.delay_jobs = false
|
9
|
+
|
10
|
+
ActiveRecord::Schema.define do
|
11
|
+
create_table :delayed_jobs, :force => true do |table|
|
12
|
+
table.integer :priority, :default => 0
|
13
|
+
table.integer :attempts, :default => 0
|
14
|
+
table.text :handler
|
15
|
+
table.text :last_error
|
16
|
+
table.datetime :run_at
|
17
|
+
table.datetime :locked_at
|
18
|
+
table.datetime :failed_at
|
19
|
+
table.string :locked_by
|
20
|
+
table.string :queue
|
21
|
+
table.timestamps
|
22
|
+
end
|
23
|
+
|
24
|
+
add_index :delayed_jobs, [:priority, :run_at], :name => 'delayed_jobs_priority'
|
25
|
+
|
26
|
+
end
|
metadata
CHANGED
@@ -1,171 +1,172 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: association_observers
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 19
|
5
5
|
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 6
|
10
|
+
version: 0.0.6
|
6
11
|
platform: ruby
|
7
|
-
authors:
|
12
|
+
authors:
|
8
13
|
- Tiago Cardoso
|
9
14
|
autorequire:
|
10
15
|
bindir: bin
|
11
16
|
cert_chain: []
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
+
|
18
|
+
date: 2013-04-25 00:00:00 Z
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
version_requirements: &id001 !ruby/object:Gem::Requirement
|
17
22
|
none: false
|
18
|
-
requirements:
|
23
|
+
requirements:
|
19
24
|
- - ~>
|
20
|
-
- !ruby/object:Gem::Version
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
hash: 11
|
27
|
+
segments:
|
28
|
+
- 0
|
29
|
+
- 9
|
30
|
+
- 2
|
31
|
+
- 2
|
21
32
|
version: 0.9.2.2
|
22
|
-
type: :development
|
23
33
|
prerelease: false
|
24
|
-
|
34
|
+
type: :development
|
35
|
+
name: rake
|
36
|
+
requirement: *id001
|
37
|
+
- !ruby/object:Gem::Dependency
|
38
|
+
version_requirements: &id002 !ruby/object:Gem::Requirement
|
25
39
|
none: false
|
26
|
-
requirements:
|
40
|
+
requirements:
|
27
41
|
- - ~>
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
requirements:
|
35
|
-
- - '='
|
36
|
-
- !ruby/object:Gem::Version
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
hash: 3
|
44
|
+
segments:
|
45
|
+
- 0
|
46
|
+
- 6
|
47
|
+
- 2
|
37
48
|
version: 0.6.2
|
38
|
-
type: :development
|
39
49
|
prerelease: false
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
version: 0.6.2
|
46
|
-
- !ruby/object:Gem::Dependency
|
47
|
-
name: rspec
|
48
|
-
requirement: !ruby/object:Gem::Requirement
|
50
|
+
type: :development
|
51
|
+
name: rack-test
|
52
|
+
requirement: *id002
|
53
|
+
- !ruby/object:Gem::Dependency
|
54
|
+
version_requirements: &id003 !ruby/object:Gem::Requirement
|
49
55
|
none: false
|
50
|
-
requirements:
|
56
|
+
requirements:
|
51
57
|
- - ~>
|
52
|
-
- !ruby/object:Gem::Version
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
hash: 35
|
60
|
+
segments:
|
61
|
+
- 2
|
62
|
+
- 11
|
63
|
+
- 0
|
53
64
|
version: 2.11.0
|
54
|
-
type: :development
|
55
65
|
prerelease: false
|
56
|
-
|
66
|
+
type: :development
|
67
|
+
name: rspec
|
68
|
+
requirement: *id003
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
version_requirements: &id004 !ruby/object:Gem::Requirement
|
57
71
|
none: false
|
58
|
-
requirements:
|
72
|
+
requirements:
|
59
73
|
- - ~>
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
requirements:
|
67
|
-
- - '='
|
68
|
-
- !ruby/object:Gem::Version
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
hash: 63
|
76
|
+
segments:
|
77
|
+
- 0
|
78
|
+
- 8
|
79
|
+
- 0
|
69
80
|
version: 0.8.0
|
70
|
-
type: :development
|
71
81
|
prerelease: false
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
version: 0.8.0
|
78
|
-
- !ruby/object:Gem::Dependency
|
79
|
-
name: colorize
|
80
|
-
requirement: !ruby/object:Gem::Requirement
|
82
|
+
type: :development
|
83
|
+
name: database_cleaner
|
84
|
+
requirement: *id004
|
85
|
+
- !ruby/object:Gem::Dependency
|
86
|
+
version_requirements: &id005 !ruby/object:Gem::Requirement
|
81
87
|
none: false
|
82
|
-
requirements:
|
83
|
-
- -
|
84
|
-
- !ruby/object:Gem::Version
|
88
|
+
requirements:
|
89
|
+
- - ~>
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
hash: 27
|
92
|
+
segments:
|
93
|
+
- 0
|
94
|
+
- 5
|
95
|
+
- 8
|
85
96
|
version: 0.5.8
|
86
|
-
type: :development
|
87
97
|
prerelease: false
|
88
|
-
|
98
|
+
type: :development
|
99
|
+
name: colorize
|
100
|
+
requirement: *id005
|
101
|
+
- !ruby/object:Gem::Dependency
|
102
|
+
version_requirements: &id006 !ruby/object:Gem::Requirement
|
89
103
|
none: false
|
90
|
-
requirements:
|
91
|
-
- -
|
92
|
-
- !ruby/object:Gem::Version
|
93
|
-
|
94
|
-
|
104
|
+
requirements:
|
105
|
+
- - ">="
|
106
|
+
- !ruby/object:Gem::Version
|
107
|
+
hash: 3
|
108
|
+
segments:
|
109
|
+
- 0
|
110
|
+
version: "0"
|
111
|
+
prerelease: false
|
112
|
+
type: :development
|
95
113
|
name: pry
|
96
|
-
requirement:
|
114
|
+
requirement: *id006
|
115
|
+
- !ruby/object:Gem::Dependency
|
116
|
+
version_requirements: &id007 !ruby/object:Gem::Requirement
|
97
117
|
none: false
|
98
|
-
requirements:
|
99
|
-
- -
|
100
|
-
- !ruby/object:Gem::Version
|
101
|
-
|
102
|
-
|
118
|
+
requirements:
|
119
|
+
- - ">="
|
120
|
+
- !ruby/object:Gem::Version
|
121
|
+
hash: 3
|
122
|
+
segments:
|
123
|
+
- 0
|
124
|
+
version: "0"
|
103
125
|
prerelease: false
|
104
|
-
|
105
|
-
none: false
|
106
|
-
requirements:
|
107
|
-
- - ! '>='
|
108
|
-
- !ruby/object:Gem::Version
|
109
|
-
version: '0'
|
110
|
-
- !ruby/object:Gem::Dependency
|
126
|
+
type: :development
|
111
127
|
name: pry-doc
|
112
|
-
requirement:
|
128
|
+
requirement: *id007
|
129
|
+
- !ruby/object:Gem::Dependency
|
130
|
+
version_requirements: &id008 !ruby/object:Gem::Requirement
|
113
131
|
none: false
|
114
|
-
requirements:
|
115
|
-
- -
|
116
|
-
- !ruby/object:Gem::Version
|
117
|
-
|
118
|
-
|
132
|
+
requirements:
|
133
|
+
- - ">="
|
134
|
+
- !ruby/object:Gem::Version
|
135
|
+
hash: 3
|
136
|
+
segments:
|
137
|
+
- 0
|
138
|
+
version: "0"
|
119
139
|
prerelease: false
|
120
|
-
|
121
|
-
none: false
|
122
|
-
requirements:
|
123
|
-
- - ! '>='
|
124
|
-
- !ruby/object:Gem::Version
|
125
|
-
version: '0'
|
126
|
-
- !ruby/object:Gem::Dependency
|
140
|
+
type: :development
|
127
141
|
name: awesome_print
|
128
|
-
requirement:
|
142
|
+
requirement: *id008
|
143
|
+
- !ruby/object:Gem::Dependency
|
144
|
+
version_requirements: &id009 !ruby/object:Gem::Requirement
|
129
145
|
none: false
|
130
|
-
requirements:
|
131
|
-
- -
|
132
|
-
- !ruby/object:Gem::Version
|
133
|
-
|
134
|
-
|
146
|
+
requirements:
|
147
|
+
- - ">="
|
148
|
+
- !ruby/object:Gem::Version
|
149
|
+
hash: 3
|
150
|
+
segments:
|
151
|
+
- 0
|
152
|
+
version: "0"
|
135
153
|
prerelease: false
|
136
|
-
version_requirements: !ruby/object:Gem::Requirement
|
137
|
-
none: false
|
138
|
-
requirements:
|
139
|
-
- - ! '>='
|
140
|
-
- !ruby/object:Gem::Version
|
141
|
-
version: '0'
|
142
|
-
- !ruby/object:Gem::Dependency
|
143
|
-
name: activesupport
|
144
|
-
requirement: !ruby/object:Gem::Requirement
|
145
|
-
none: false
|
146
|
-
requirements:
|
147
|
-
- - ! '>='
|
148
|
-
- !ruby/object:Gem::Version
|
149
|
-
version: '0'
|
150
154
|
type: :runtime
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
description: ! "This is an alternative implementation of the observer pattern. As
|
159
|
-
you may know, Ruby (and Rails/ActiveRecord) already have an\n implementation of
|
160
|
-
it. This implementation is a variation of the pattern, so it is not supposed to
|
161
|
-
supersede the existing\n implementations, but \"complete\" them for the specific
|
162
|
-
use-cases addressed."
|
163
|
-
email:
|
155
|
+
name: activesupport
|
156
|
+
requirement: *id009
|
157
|
+
description: |-
|
158
|
+
This is an alternative implementation of the observer pattern. As you may know, Ruby (and Rails/ActiveRecord) already have an
|
159
|
+
implementation of it. This implementation is a variation of the pattern, so it is not supposed to supersede the existing
|
160
|
+
implementations, but "complete" them for the specific use-cases addressed.
|
161
|
+
email:
|
164
162
|
- cardoso_tiago@hotmail.com
|
165
163
|
executables: []
|
164
|
+
|
166
165
|
extensions: []
|
166
|
+
|
167
167
|
extra_rdoc_files: []
|
168
|
-
|
168
|
+
|
169
|
+
files:
|
169
170
|
- .gitignore
|
170
171
|
- .pryrc
|
171
172
|
- .rspec
|
@@ -177,62 +178,79 @@ files:
|
|
177
178
|
- association_observers.gemspec
|
178
179
|
- database.yml
|
179
180
|
- lib/association_observers.rb
|
180
|
-
- lib/association_observers/
|
181
|
-
- lib/association_observers/
|
181
|
+
- lib/association_observers/active_record.rb
|
182
|
+
- lib/association_observers/data_mapper.rb
|
183
|
+
- lib/association_observers/extensions/delayed_job.rb
|
184
|
+
- lib/association_observers/extensions/resque.rb
|
185
|
+
- lib/association_observers/extensions/sidekiq.rb
|
182
186
|
- lib/association_observers/notifiers/base.rb
|
183
187
|
- lib/association_observers/notifiers/propagation_notifier.rb
|
188
|
+
- lib/association_observers/orm/active_record.rb
|
189
|
+
- lib/association_observers/orm/base.rb
|
190
|
+
- lib/association_observers/orm/data_mapper.rb
|
191
|
+
- lib/association_observers/queue.rb
|
184
192
|
- lib/association_observers/railtie.rb
|
185
193
|
- lib/association_observers/ruby18.rb
|
186
194
|
- lib/association_observers/version.rb
|
195
|
+
- lib/association_observers/workers/many_delayed_notification.rb
|
187
196
|
- lib/examples/notifiers/update_timestamp_notifier.rb
|
188
197
|
- lib/examples/readme_example.rb
|
189
|
-
- spec/active_record_helper.rb
|
190
198
|
- spec/activerecord/association_observers_spec.rb
|
199
|
+
- spec/activerecord/delayed_job/association_observers_spec.rb
|
191
200
|
- spec/activerecord/readme_example_spec.rb
|
201
|
+
- spec/activerecord/resque/association_observers_spec.rb
|
202
|
+
- spec/activerecord/sidekiq/association_observers_spec.rb
|
192
203
|
- spec/datamapper/association_observers_spec.rb
|
193
|
-
- spec/
|
204
|
+
- spec/helpers/active_record_helper.rb
|
205
|
+
- spec/helpers/datamapper_helper.rb
|
206
|
+
- spec/helpers/delayed_job_helper.rb
|
207
|
+
- spec/helpers/resque_helper.rb
|
208
|
+
- spec/helpers/sidekiq_helper.rb
|
194
209
|
- spec/spec_helper.rb
|
195
210
|
homepage: https://github.com/TiagoCardoso1983/association_observers
|
196
211
|
licenses: []
|
212
|
+
|
197
213
|
post_install_message:
|
198
214
|
rdoc_options: []
|
199
|
-
|
215
|
+
|
216
|
+
require_paths:
|
200
217
|
- lib
|
201
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
218
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
202
219
|
none: false
|
203
|
-
requirements:
|
204
|
-
- -
|
205
|
-
- !ruby/object:Gem::Version
|
206
|
-
|
207
|
-
segments:
|
220
|
+
requirements:
|
221
|
+
- - ">="
|
222
|
+
- !ruby/object:Gem::Version
|
223
|
+
hash: 3
|
224
|
+
segments:
|
208
225
|
- 0
|
209
|
-
|
210
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
226
|
+
version: "0"
|
227
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
211
228
|
none: false
|
212
|
-
requirements:
|
213
|
-
- -
|
214
|
-
- !ruby/object:Gem::Version
|
215
|
-
|
216
|
-
segments:
|
229
|
+
requirements:
|
230
|
+
- - ">="
|
231
|
+
- !ruby/object:Gem::Version
|
232
|
+
hash: 3
|
233
|
+
segments:
|
217
234
|
- 0
|
218
|
-
|
235
|
+
version: "0"
|
219
236
|
requirements: []
|
237
|
+
|
220
238
|
rubyforge_project:
|
221
239
|
rubygems_version: 1.8.24
|
222
240
|
signing_key:
|
223
241
|
specification_version: 3
|
224
|
-
summary:
|
225
|
-
|
226
|
-
"actions") to notify the observer. The observer knows what to do when notified. What''s
|
227
|
-
the limitation? The observed has to know when and whom to notify. The observer has
|
228
|
-
to know what to do. For this logic to be implemented for two other separate entities,
|
229
|
-
behaviour has to be copied from one place to the other. So, why not delegate this
|
230
|
-
information (to whom, when, behaviour) to a third role, the notifier?'
|
231
|
-
test_files:
|
232
|
-
- spec/active_record_helper.rb
|
242
|
+
summary: "The Observer Pattern clearly defines two roles: the observer and the observed. The observer registers itself by the observed. The observed decides when (for which \"actions\") to notify the observer. The observer knows what to do when notified. What's the limitation? The observed has to know when and whom to notify. The observer has to know what to do. For this logic to be implemented for two other separate entities, behaviour has to be copied from one place to the other. So, why not delegate this information (to whom, when, behaviour) to a third role, the notifier?"
|
243
|
+
test_files:
|
233
244
|
- spec/activerecord/association_observers_spec.rb
|
245
|
+
- spec/activerecord/delayed_job/association_observers_spec.rb
|
234
246
|
- spec/activerecord/readme_example_spec.rb
|
247
|
+
- spec/activerecord/resque/association_observers_spec.rb
|
248
|
+
- spec/activerecord/sidekiq/association_observers_spec.rb
|
235
249
|
- spec/datamapper/association_observers_spec.rb
|
236
|
-
- spec/
|
250
|
+
- spec/helpers/active_record_helper.rb
|
251
|
+
- spec/helpers/datamapper_helper.rb
|
252
|
+
- spec/helpers/delayed_job_helper.rb
|
253
|
+
- spec/helpers/resque_helper.rb
|
254
|
+
- spec/helpers/sidekiq_helper.rb
|
237
255
|
- spec/spec_helper.rb
|
238
256
|
has_rdoc:
|