Skip to content

New ruby hash syntax and SymbolOperator #39

disbelief opened this Issue Aug 28, 2013 · 3 comments

3 participants


Wondering if there's any way to get Plucky's SymbolOperator to work with Ruby's new hash syntax?

For example is there a way to get:

People.where =>

to use the form:

People.where created_at:

but somehow apply the .lt operator?

Having the two forms sprinkled throughout a codebase, depending on whether I need an operator or not, is really messy.

MongoMapper member
cheald commented Aug 28, 2013

Not as far as I'm aware. #lt is a method that is extended onto Symbol, so unless Ruby can figure out that created_at is a symbol, then calling #lt on it isn't going to have the intended effect. I believe this is a Ruby issue rather than a Plucky issue.

If anyone's aware of a different mechanism, I'd love to hear of it. :)


Thanks, I had figured as much but wanted to make sure I wasn't missing something obvious.


You could do something like this:

class GtExt
  def [](val)
    {:$gt => val}

$gt =

People.where created_at: $gt[]

Or you could be really hacky and add it right into Kernel

module Kernel
  def GreaterThan(val)
    { :$gt => val }

People.where created_at: GreaterThan

Right-wing coders might disapprove though. :smile:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.