Paperclip::Attachment#post_process_styles gets arguments in recent Paperclip versions (at least in 2.4.5 and 2.5.0), so avoid "wrong number of arguments" errors
Paperclip::Attachment#post_process_styles gets arguments in recent Pa…
…perclip versions, so avoid "wrong number of arguments" errors
It will be nice to check is original_post_process_styles really accept arguments, to maintain backward compatibility. Something like this
# Since arity return 0 only in case when there no arguments for method, and negative numbers when splat operator used,
# we should check only 0 value to pass arguments to original method
method(:original_post_process_styles).arity == 0 ? original_post_process_styles : original_post_process_styles(*args)
Don't forget to pass arguments to method with splat operator (*args). Right now you capture arguments to array and then pass it as first argument, which is not correct.
Update #post_process_styles to be more correct, and backwards compatible
Backwards compatibility might be nice. And I can't ever seem to remember if the second splat operator is needed or not. Added both.
If you use splat operator with array as method argument it will pass each array element as independent argument. For example:
p *[1,2,3] # It's equal calling p with three arguments: p(1,2,3)
And without splat it will be:
p [1,2,3] # It's just calling p with array as first argument
Merge pull request #8 from PerfectlyNormal/patch-1
Add arguments to `post_process_styles` method to be compatible with Paperclip v2.3.9 and older.