Permalink
Browse files

Change big elsif to case

  • Loading branch information...
Ostrzy committed Jul 27, 2012
1 parent da56475 commit 27c219a619f13967bcc2d86c221149b662b28258
Showing with 5 additions and 4 deletions.
  1. +5 −4 lib/active_admin/mongoid/adaptor.rb
@@ -39,13 +39,14 @@ def get_query_hash(search_params)
end
def mongoidify_search(k, v)
- if k =~ /_contains$/
+ case k
+ when /_contains$/
[get_attribute(k, '_contains'), Regexp.new(Regexp.escape("#{v}"), Regexp::IGNORECASE)]
- elsif k =~ /_eq$/
+ when /_eq$/
[get_attribute(k, '_eq'), v]
- elsif k =~ /_gt$/
+ when /_gt$/
[get_attribute(k, "_gt").to_sym.gt, v]
- elsif k =~ /_lt$/
+ when /_lt$/
[get_attribute(k, "_lt").to_sym.lt, v]
else
[k, v]

0 comments on commit 27c219a

Please sign in to comment.