Commit 49faabb3 by Tute Costa

Update callbacks for Rails 5

Ref: https://github.com/rails/rails/commit/2386daabe7f8c979b453010dc0de3e1f6bbf859d

Specifically:

> Chains of callbacks defined **with** a `:terminator` option will
> maintain their existing behavior of halting as soon as a `before_`
> callback matches the terminator's expectation. For instance,
> ActiveModel's callbacks will still halt the chain when a `before_`
> callback returns `false`.

In terminator callbacks, the `result` value changed to be a lambda now.
This change reflects that, updating the terminator to compare the result
of the block to `false`.

Also:

* Removes Rails 4.1 branch (we don't support it anymore)
* Rewrite for legibility: change `unless` for `if`
parent 393aac2c
...@@ -501,7 +501,7 @@ module Paperclip ...@@ -501,7 +501,7 @@ module Paperclip
instance.run_paperclip_callbacks(:post_process) do instance.run_paperclip_callbacks(:post_process) do
instance.run_paperclip_callbacks(:"#{name}_post_process") do instance.run_paperclip_callbacks(:"#{name}_post_process") do
unless @options[:check_validity_before_processing] && instance.errors.any? if !@options[:check_validity_before_processing] || !instance.errors.any?
post_process_styles(*style_args) post_process_styles(*style_args)
end end
end end
......
...@@ -23,10 +23,12 @@ module Paperclip ...@@ -23,10 +23,12 @@ module Paperclip
private private
def hasta_la_vista_baby def hasta_la_vista_baby
if ::ActiveSupport::VERSION::STRING >= "5.0" lambda do |_, result|
lambda { |_, result| result.call } if result.respond_to?(:call)
else result.call == false
'result == false' else
result == false
end
end end
end end
end end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment