-
Notifications
You must be signed in to change notification settings - Fork 60
Open
Labels
Description
Let's say we have a simple Mongoid model:
class Article
include SimpleEnum::Mongoid
VALID_TYPES = { blog: 0, vlog: 1, xlog: 2 }
# ...
as_enum :type, VALID_TYPES, source: :type
endAs far as I can see (correct me if I'm wrong!), it's not possible to query using a selector that takes the symbol corresponding to a value of an enum, like this:
Article.where(type: :blog).countwhile instead is possible to do this:
Article.where(type: 0).count
Article.where(type: Article::VALID_TYPES[:blog]).count # or this, don't like it thoughI'm aware of the fact that it's possible to use chained selectors, like this:
Article.blogs.countbut in our codebase we often build selectors as hashes that are passed to instances of different classes.
Besides this maybe not being the best approach of all times, IMHO it'd be very beneficial to be able to consume the gem in a consistent way, always passing the symbol (key of the hash), not the value.
Do you think it's a complicated matter? Can you give me pointers to where to look at, so maybe I can submit a PR?
softbrada