protected_record_manager 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +17 -0
- data/app/mailers/protected_record_manager/change_request_mailer.rb +13 -0
- data/app/models/protected_record_manager/configuration.rb +11 -0
- data/app/views/protected_record_manager/change_request_mailer/notify.html.erb +9 -0
- data/config/initializers/change_request_subscription.rb +10 -0
- data/lib/protected_record_manager/version.rb +1 -1
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7717e4d831e716328bba250170a848a62af49fe2
|
4
|
+
data.tar.gz: 8cf4b482a98b0396a10de203e6ddec287856fb57
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e5debd4c7ec63e5558f77ef2445ab3ca6c68bbb543afe73fe530f90c5cf7f1337bdb01874aa7dcfcb4d45c766998429c204a3427fe35832f7e0327d20496559b
|
7
|
+
data.tar.gz: 9053d355b3a8495b9fb3626818da8a6e077d9a32be3ed4e48135c62f66af4cd48e6956fcaf93b306d21680f12f892c9c5a405c8ecca3c2d803fa50ed5a260f56
|
data/README.md
CHANGED
@@ -42,6 +42,23 @@ $ rake protected_record_manager:install:migrations
|
|
42
42
|
$ rake db:migrate
|
43
43
|
```
|
44
44
|
|
45
|
+
### Events & Notifications
|
46
|
+
|
47
|
+
I've added an [initializer](https://github.com/rthbound/protected_record_manager/blob/master/config/initializers/change_request_subscription.rb) which subscribes to instrumentations of the "protected_record_change_request" event.
|
48
|
+
|
49
|
+
To fire the email, you will need to instrument the event yourself (example provided). If you fail to provide a change request object when you instrument the event, nothing will happen. The email will be sent to all users where `user.protected_record_manager #=> true`.
|
50
|
+
|
51
|
+
```ruby
|
52
|
+
ActiveSupport::Notifications.instrument("protected_record_change_request", {
|
53
|
+
change_request: update_result.data[:change_request],
|
54
|
+
record_managers: User.where(protected_record_manager: true)
|
55
|
+
})
|
56
|
+
```
|
57
|
+
|
58
|
+
To set the default from address, create in your rails app an initializer that does the following: `ProtectedRecordManager::Configuration.default_from = "foo@bar.com"`
|
59
|
+
|
60
|
+
Unless you configure a default from address, this engine will use "no-reply@example.com"
|
61
|
+
|
45
62
|
## Contributing
|
46
63
|
|
47
64
|
Please do. There's plenty that could be done to round out both the interface
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module ProtectedRecordManager
|
2
|
+
class ChangeRequestMailer < ActionMailer::Base
|
3
|
+
default from: ProtectedRecordManager::Configuration.default_from
|
4
|
+
|
5
|
+
def notify(users, change_request)
|
6
|
+
@url = change_request_url(change_request)
|
7
|
+
mail({
|
8
|
+
to: users.collect(&:email).join(","),
|
9
|
+
subject: "New Change Request from #{change_request.user.email}"
|
10
|
+
})
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
ActiveSupport::Notifications.subscribe("protected_record_change_request") do |*args|
|
2
|
+
event = ActiveSupport::Notifications::Event.new(*args)
|
3
|
+
request = event.payload[:change_request]
|
4
|
+
|
5
|
+
if request.present?
|
6
|
+
users = event.payload[:record_managers]
|
7
|
+
|
8
|
+
ProtectedRecordManager::ChangeRequestMailer.notify(users, request).deliver
|
9
|
+
end
|
10
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: protected_record_manager
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tad Hosford
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-05-
|
11
|
+
date: 2013-05-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -60,11 +60,13 @@ executables: []
|
|
60
60
|
extensions: []
|
61
61
|
extra_rdoc_files: []
|
62
62
|
files:
|
63
|
+
- app/mailers/protected_record_manager/change_request_mailer.rb
|
63
64
|
- app/assets/javascripts/protected_record_manager/application.js
|
64
65
|
- app/assets/stylesheets/protected_record_manager/application.css
|
65
66
|
- app/assets/stylesheets/protected_record_manager/change_request.css
|
66
67
|
- app/helpers/protected_record_manager/application_helper.rb
|
67
68
|
- app/helpers/protected_record_manager/change_requests_helper.rb
|
69
|
+
- app/models/protected_record_manager/configuration.rb
|
68
70
|
- app/controllers/protected_record_manager/change_requests_controller.rb
|
69
71
|
- app/controllers/protected_record_manager/application_controller.rb
|
70
72
|
- app/views/layouts/protected_record_manager/application.html.erb
|
@@ -72,7 +74,9 @@ files:
|
|
72
74
|
- app/views/protected_record_manager/change_requests/_form.html.erb
|
73
75
|
- app/views/protected_record_manager/change_requests/edit.html.erb
|
74
76
|
- app/views/protected_record_manager/change_requests/index.html.erb
|
77
|
+
- app/views/protected_record_manager/change_request_mailer/notify.html.erb
|
75
78
|
- config/routes.rb
|
79
|
+
- config/initializers/change_request_subscription.rb
|
76
80
|
- db/migrate/20130424195950_create_protected_record_change_log_records.rb
|
77
81
|
- db/migrate/20130424181224_add_protected_record_manager_to_users.rb
|
78
82
|
- db/migrate/20130424195959_create_protected_record_change_request_records.rb
|