Skip to content

Instantly share code, notes, and snippets.

@joxxoxo
Created May 18, 2013 09:57
Show Gist options
  • Save joxxoxo/5603919 to your computer and use it in GitHub Desktop.
Save joxxoxo/5603919 to your computer and use it in GitHub Desktop.
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
@joxxoxo
Copy link
Author

joxxoxo commented May 18, 2013

search_params = self.search_params

this is used in other methods that need search_params inside instance eval

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment