error invocation in sequel/lib/sequel/plugins/validation_helpers.rb:233 #530

Closed
crhan opened this Issue Aug 4, 2012 · 3 comments

Projects

None yet

2 participants

@crhan
crhan commented Aug 4, 2012

If I defined the send method in my model, and use the validation helper.

at sequel/lib/sequel/plugins/validation_helpers.rb:233 here will invoke my send method but not the Kernel#send

I suggest to use __send__ instead of send here

@jeremyevans
Owner

If you override send, you are going to have more problems than just validation helpers. send is used all over Sequel. I'm sorry, but I don't plan on changing all send calls in Sequel to __send__. While overriding send is allowed, it is very bad form to do so and not call super, and will confuse most rubyists who read your code. Changing from using send to __send__ would encourage bad form, as well as make the Sequel internal code harder to read. I recommend you choose a different method name than send in your model code.

@jeremyevans jeremyevans closed this Aug 4, 2012
@crhan
crhan commented Aug 4, 2012

but sometimes overriding send method is such meaningful. see here, that example means send xml to the client stream.

@jeremyevans
Owner

Sometimes overriding object_id is meaningful (i.e. as a Sequel column method for a column named object_id), but that doesn't make it a good choice for a ruby method name. Overriding ruby core methods and changing their meaning is a bad idea, just choose a different name for your model method.

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