junk_drawer 1.6.3 → 1.7.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c19a96b9707d53151fb3edf626ce443ad60cb4503ac75b108bd46eb6d7694f54
4
- data.tar.gz: a4e87efeacae9353c7784dbad2a47294292b088c39fb50f5ad387dec2a8dcaa9
3
+ metadata.gz: 41bdf84aed0cada468a2754eaeb98650346f35789f2ffaae69b2b79026abe720
4
+ data.tar.gz: 7e8394ce972f2eeb72d2c28ba5966a67da30f1561575595d329d8533781a3c46
5
5
  SHA512:
6
- metadata.gz: 19a935285fd80b81d4d7c432f1775196032f766bdc78df61967b504d433566be1a36e04992c6266466fc5c480ff69aaef4edf21705ef48e6d9fbd4d9cfa0fffa
7
- data.tar.gz: 2ad821ea7cc213f62c55bd07e96394fe1ea3618684bc13dea806cf83bb94cae883dc8bc392dd988e6ee1f6d80dfdf8e91459fb1907a58666ebca919fe50daa75
6
+ metadata.gz: 55ae0cc6d20c582a88be1cd28d92bb2942ffc44d671aabff3cc4d6c6dbd3c1ee61d5232f2e86d6cfa44422d98c8daf86563c097db6ef078261d584a80c389c9a
7
+ data.tar.gz: 07d25dce3efde1f44f6d41382453d2e3b1d9f7c2cf7d5658006acd6bf21ecfe4c62237e64a3a324094d1bf17ea6ca7a023395ae09da531a07830fa7538941308
data/.gitignore CHANGED
@@ -8,3 +8,4 @@
8
8
  /pkg/
9
9
  /spec/reports/
10
10
  /tmp/
11
+ vendor/
data/README.md CHANGED
@@ -27,9 +27,18 @@ gem 'junk_drawer', require: 'junk_drawer/rails'
27
27
 
28
28
  ### Contents
29
29
 
30
- - [JunkDrawer::Callable](#junkdrawercallable)
31
- - [JunkDrawer::Notifier](#junkdrawernotifier)
32
- - [JunkDrawer::BulkUpdatable](#junkdrawerbulkupdatable)
30
+ - [JunkDrawer](#junkdrawer)
31
+ - [Installation](#installation)
32
+ - [Contents](#contents)
33
+ - [Usage](#usage)
34
+ - [JunkDrawer::Callable](#junkdrawercallable)
35
+ - [JunkDrawer::Notifier](#junkdrawernotifier)
36
+ - [Rails](#rails)
37
+ - [JunkDrawer::BulkUpdatable](#junkdrawerbulkupdatable)
38
+ - [Caveats](#caveats)
39
+ - [Development](#development)
40
+ - [Contributing](#contributing)
41
+ - [License](#license)
33
42
 
34
43
  ## Usage
35
44
 
@@ -129,6 +138,28 @@ your selected strategy. The strategies available are as follows:
129
138
  3) `:null` is a noop. If you want to disable notifications temporarily, you can
130
139
  configure the strategy to `:null`.
131
140
 
141
+ 4) To create your own custom notifier, configure `JunkDrawer::Notifier` with
142
+ a callable object as the strategy.
143
+
144
+ ```ruby
145
+ class MyNotifier
146
+ include JunkDrawer::Callable
147
+
148
+ def call(*args)
149
+ SomeMonitoringService.notify(*args)
150
+ end
151
+ end
152
+
153
+ JunkDrawer::Notifier.strategy = MyNotifier
154
+ ```
155
+
156
+ ```ruby
157
+ JunkDrawer::Notifier.strategy = ->(*args) {
158
+ MonitoringServiceA.notify(*args)
159
+ MonitoringServiceB.notify(*args)
160
+ }
161
+ ```
162
+
132
163
  If you're using Rails, you may want to configure `Notifier` based on the
133
164
  environment, so in your `config/environments/development.rb` you might have:
134
165
 
@@ -12,7 +12,12 @@ module JunkDrawer
12
12
 
13
13
  class << self
14
14
 
15
- attr_accessor :strategy
15
+ attr_reader :strategy
16
+
17
+ def strategy=(strategy)
18
+ @strategy =
19
+ strategy.is_a?(Symbol) ? STRATEGIES.fetch(strategy) : strategy
20
+ end
16
21
 
17
22
  end
18
23
 
@@ -23,13 +28,7 @@ module JunkDrawer
23
28
  }.freeze
24
29
 
25
30
  def call(*args)
26
- strategy.(*args)
27
- end
28
-
29
- private
30
-
31
- def strategy
32
- STRATEGIES.fetch(self.class.strategy)
31
+ self.class.strategy.(*args)
33
32
  end
34
33
 
35
34
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module JunkDrawer
4
- VERSION = '1.6.3'
4
+ VERSION = '1.7.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: junk_drawer
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.3
4
+ version: 1.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Fletcher
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-09-24 00:00:00.000000000 Z
11
+ date: 2020-10-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ruby2_keywords