snfoil-context 1.2.0 → 1.2.1

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
  SHA256:
3
- metadata.gz: 6c8dbabb2362b9f056aa022c30b3b272a66f77c9316e65693f3b1a62312b7f70
4
- data.tar.gz: 6bbb3416847d30ffc991751760076cbe709b127a203c2172bbe13d600ae55c00
3
+ metadata.gz: 3c0a135f165751090edfb064b8af3fe1290c8d4a43826dd1e613e466d0c70632
4
+ data.tar.gz: c1c7e5e532f45c44b387a7ac783d5d4c861287184e0fab76778d9314d72c325e
5
5
  SHA512:
6
- metadata.gz: aa99ee8c5289136c65ab060112b33e664d92fc866d43cc131f6c783159c2c81e9213d25789955360e41758835ee4b3068b17546131598474a63513d35a8ffc66
7
- data.tar.gz: 779f732fe717014a137e8450465e0cde4be9bd4e13080674af794aefcb2f5a2eeb162f4e0f66568d24199b2a0b89d5c975b37a0643d7b67ac25e86bfc18818a8
6
+ metadata.gz: '00820f4a6801a17d7979b0c8d4ebd8b55ae8f21112e5816ba1b7df8b77baf91a27b596234993474e9bac85208882b23c0d57b203caa93195aaf53a01f5de7b67'
7
+ data.tar.gz: 0f60091640051b9e57ab235abb479bb9d02d495ab27aa0186476cf0d856372560e33ec344476548b80790e1e1a8305cfa4749a109f022d50d739511b2e2aed08
data/README.md CHANGED
@@ -309,6 +309,14 @@ end
309
309
  #### Why before and after?
310
310
  Simply to make sure the entity is allowed access to the primary target and is allowed to make the requested alterations/interactions.
311
311
 
312
+ #### Did Authorize Run?
313
+ If there is a valid policy to call SnFoil-Context will update the `:authorize` key in the options.
314
+
315
+ Values are:
316
+ - `false` - The authorize method never ran
317
+ - `:setup` - The authorize method ran after the setup interval (the first run)
318
+ - `:before` - The authorize method ran after the before interval (the second run)
319
+
312
320
  ### Intervals
313
321
  There might be a situation where you don't need a before, after, success or failure, and just need a single name pipeline you can hook into. `interval` allows you to create a single action-like segment.
314
322
 
@@ -16,6 +16,6 @@
16
16
 
17
17
  module SnFoil
18
18
  module Context
19
- VERSION = '1.2.0'
19
+ VERSION = '1.2.1'
20
20
  end
21
21
  end
@@ -74,20 +74,14 @@ module SnFoil
74
74
  def define_action_primary(name, method, block) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
75
75
  define_method(name) do |*_args, **options| # rubocop:disable Metrics/MethodLength
76
76
  options[:action] ||= name.to_sym
77
- options[:authorized] = false
78
77
 
79
78
  options = run_interval(format('setup_%s', name), **options)
80
79
 
81
- if respond_to?(:authorize)
82
- authorize(name, **options)
83
- options[:authorized] = :setup
84
- end
80
+ authorize(name, **options) if respond_to?(:authorize) && !options[:skip_first_authorize]
85
81
 
86
82
  options = run_interval(format('before_%s', name), **options)
87
- if respond_to?(:authorize)
88
- authorize(name, **options)
89
- options[:authorized] = :before
90
- end
83
+
84
+ authorize(name, **options) if respond_to?(:authorize) && !options[:skip_last_authorize]
91
85
 
92
86
  options = if run_action_primary(method, block, **options)
93
87
  run_interval(format('after_%s_success', name), **options)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: snfoil-context
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matthew Howes
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2022-12-14 00:00:00.000000000 Z
12
+ date: 2023-03-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport