Compatibility with recent Paperclip #8

Merged
merged 2 commits into from Jan 25, 2012

Conversation

Projects
None yet
2 participants
Contributor

PerfectlyNormal commented Jan 25, 2012

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

@PerfectlyNormal PerfectlyNormal Paperclip::Attachment#post_process_styles gets arguments in recent Pa…
…perclip versions, so avoid "wrong number of arguments" errors
8128c55
Collaborator

y8 commented Jan 25, 2012

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.

A.

Contributor

PerfectlyNormal commented Jan 25, 2012

Backwards compatibility might be nice. And I can't ever seem to remember if the second splat operator is needed or not. Added both.

Collaborator

y8 commented Jan 25, 2012

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)
1
2
3

And without splat it will be:

p [1,2,3] # It's just calling p with array as first argument
[1,2,3]

@y8 y8 added a commit that referenced this pull request Jan 25, 2012

@y8 y8 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.
b4d86b8

@y8 y8 merged commit b4d86b8 into teeparham:master Jan 25, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment