trying to override != or create a unary negation method

F

Francis Hwang

I'm trying to add Criteria-style query inference to Lafcadio, which so
far has involved making a class that overrides == . So far, so good.
Now I'd like to override != so that I can turn the block

{ |user| user.email != "(e-mail address removed)" }

into the sql

select * from users where !(email = '(e-mail address removed)')

The trusty Pickaxe sez you can't define != independently of ==, and
that once you've defined ==, any call to

a != b

is implicitly turned into

!(a == b)

So I figure, fine, I can make my query condition objects flip
themselves when they're negated. Tried creating a unary negation
method:

def !@
# ...
end

and just got a syntax error. Any ideas as to what I could try next?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,754
Messages
2,569,525
Members
44,997
Latest member
mileyka

Latest Threads

Top