Created
June 16, 2011 17:38
-
-
Save jacqui/1029772 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
require 'sunspot' | |
module SunspotAdapter | |
class InstanceAdapter < Sunspot::Adapters::InstanceAdapter | |
def id | |
@instance.id | |
end | |
end | |
class DataAccessor < Sunspot::Adapters::DataAccessor | |
def load(id) | |
Team.find(BSON::ObjectId.from_string(id)) | |
end | |
def load_all(ids) | |
Team.where(:_id.in => ids.map{|id| BSON::ObjectId.from_string(id)}) | |
end | |
end | |
end |
This file contains hidden or 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
require 'sunspot' | |
module SunspotAdapter | |
class InstanceAdapter < Sunspot::Adapters::InstanceAdapter | |
def id | |
@instance.id | |
end | |
end | |
class DataAccessor < Sunspot::Adapters::DataAccessor | |
def load(id) | |
@klass.find(BSON::ObjectId.from_string(id)) | |
end | |
def load_all(ids) | |
@klass.where(:_id.in => ids.map{|id| BSON::ObjectId.from_string(id)}) | |
end | |
end | |
end |
This file contains hidden or 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
require 'sunspot' | |
require 'sunspot_adapter' | |
Sunspot::Adapters::InstanceAdapter.register(SunspotAdapter::InstanceAdapter, Team) | |
Sunspot::Adapters::DataAccessor.register(SunspotAdapter::DataAccessor, Team) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment