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 != "test@test.com" }
into the sql
select * from users where !(email = ‘test@test.com’)
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?