lib/snfoil/context.rb in snfoil-context-1.1.0 vs lib/snfoil/context.rb in snfoil-context-1.2.0

- old
+ new

@@ -72,15 +72,23 @@ end def define_action_primary(name, method, block) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength define_method(name) do |*_args, **options| # rubocop:disable Metrics/MethodLength options[:action] ||= name.to_sym + options[:authorized] = false options = run_interval(format('setup_%s', name), **options) - authorize(name, **options) if respond_to?(:authorize) + if respond_to?(:authorize) + authorize(name, **options) + options[:authorized] = :setup + end + options = run_interval(format('before_%s', name), **options) - authorize(name, **options) if respond_to?(:authorize) + if respond_to?(:authorize) + authorize(name, **options) + options[:authorized] = :before + end options = if run_action_primary(method, block, **options) run_interval(format('after_%s_success', name), **options) else run_interval(format('after_%s_failure', name), **options)