-
Notifications
You must be signed in to change notification settings - Fork 213
Relation#select(&:method) does not work because of arity -1 #201
Comments
I could be misremembering, but I believe this issue was raised once before and I did some checking -- the problem was that arity could == -1 in more situations than this one, and specs broke. |
Sry for editing issue after posting. That might be true. What about checking |
That's implementation-dependent. I think in rubinius it could be a ruby block, considering that a larger fraction of its core methods are written in ruby. |
Hm. Might work. Sounds a little weird to me at first glance, though, and potentially temperamental. Since you can do |
Ok, mikz@8333095 are my changes |
OK, I'll check into it again. Like I said, I was going on memory, so very well could be wrong. :) |
I agree that |
So, I now remember the problem. It won't work under 1.8. -1 is returned if you specify a block without params, even if it's not via Symbol#to_proc. Will have to figure out a decent workaround before I can release 1.0.14. :( |
Documentation says it should work (http://www.ruby-doc.org/core-1.8.6/Proc.html#method-i-binding), but indeed At least I tried several checks (checking if On 5. 12. 2012, at 2:54, Ernie Miller notifications@github.com wrote:
|
Released 1.0.14 last night. ;) |
Nice way! 👍 |
Hi,
I've run into issue with https://github.com/ernie/squeel/blob/master/lib/squeel/adapters/active_record/relation_extensions.rb#L170
Because
:symbol.to_proc.arity == -1
(at least ruby 1.9.3) it passesrelation.select(&:valid?)
toDSL.eval
and raisesCan't create Binding from C level Proc
I believe the check should be extended to check for -1 arity.
Or check http://ruby-doc.org/core-1.9.3/Proc.html#method-i-source_location that it is defined in ruby.
Should I create patch & issue pull request?
The text was updated successfully, but these errors were encountered: