Created
May 18, 2013 09:57
-
-
Save joxxoxo/5603919 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Search | |
class AdvancedProfileSearch < ::Search::Search | |
attr_reader :search_object, :search_params | |
def initialize(search_object, search_params) | |
@search_object, @search_params = search_object, search_params | |
end | |
# https://github.com/sunspot/sunspot#readme | |
class << self | |
def perform_without_rescue(search_params) | |
Profile.solr_search do | |
search_object = ::Search::AdvancedProfileSearch.new(self, search_params) | |
search_object.search_user_type | |
end | |
end | |
end | |
############ Search Methods | |
def search_user_type | |
search_params = self.search_params | |
search_object.instance_eval do | |
any_of do | |
all_of do | |
with :verified, true | |
with :user_type, User::TYPE_SERVICEMEMBER | |
end | |
all_of do | |
with :user_type, User::TYPE_VETERAN | |
end | |
end | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
this is used in other methods that need search_params inside instance eval