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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 84693404904f04eb62754f7a4b2a5ec5db783055
4
- data.tar.gz: 26490babc58f677d0a3045d3dc34b869406fa392
3
+ metadata.gz: 7717e4d831e716328bba250170a848a62af49fe2
4
+ data.tar.gz: 8cf4b482a98b0396a10de203e6ddec287856fb57
5
5
  SHA512:
6
- metadata.gz: a0991511c53be014b543feb5f662a71d59a77945e08019387e8c7838e95d86dafbef04132df47dbefafea0c158a80aa88578e6dbab9baf758f558412b38f2fd7
7
- data.tar.gz: b574c7ca3bc1df38e99df834cd160c1402ebae8a2bc86ae904e8a61a677f15701d0078abbfafc98f9069e167b6ef6c4a1c277e30da189469b2e256d304dcd1e7
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,11 @@
1
+ module ProtectedRecordManager
2
+ module Configuration
3
+ def self.default_from=(string)
4
+ @default_from = string
5
+ end
6
+
7
+ def self.default_from
8
+ @default_from.nil? ? "no-reply@example.com" : @default_from
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,9 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta content="text/html; charset=UTF-8" http-equiv="Content-Type" />
5
+ </head>
6
+ <body>
7
+ For more information visit this link: <%= @url %>
8
+ </body>
9
+ </html>
@@ -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
@@ -1,3 +1,3 @@
1
1
  module ProtectedRecordManager
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  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.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-01 00:00:00.000000000 Z
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