This repository was archived by the owner on Dec 12, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 21
added support for mongoid #54
Open
dcu
wants to merge
15
commits into
ryanb:master
Choose a base branch
from
dcu:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
8d5e989
add mongoid adapter
dcu 4344a39
check whether active record or mongoid is included
dcu da8647e
initialize mongoid documents correctly
dcu 31d469c
include mongoid adapter
dcu 6f44a94
make use of <= operator
dcu c4b5006
update rack version
dcu dc6827c
Prevent circular references to to_json method
kuadrosx 7fad283
Merge branch 'rack13'
dcu 10c5d19
rack server must use the local database
dcu 13681d0
improve text indexer
dcu cb2df2c
allow to set the stemmer language by document
dcu 9394651
include active support
dcu b6a7a40
indexing all should use the local database otherwise it would be very…
dcu f8fbce7
added total_count alias
patcito cb30673
Merge remote-tracking branch 'upstream/master'
dcu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| module Xapit | ||
| module Client | ||
| class MongoidAdapter < AbstractModelAdapter | ||
| def self.for_class?(model_class) | ||
| defined?(Mongoid::Document) && model_class <= Mongoid::Document | ||
| end | ||
|
|
||
| def setup | ||
| @model_class.after_create do |member| | ||
| member.class.xapit_index_builder.add_document(member) if Xapit.config[:enabled] | ||
| end | ||
| @model_class.after_update do |member| | ||
| member.class.xapit_index_builder.update_document(member) if Xapit.config[:enabled] | ||
| end | ||
| @model_class.after_destroy do |member| | ||
| member.class.xapit_index_builder.remove_document(member) if Xapit.config[:enabled] | ||
| end | ||
| end | ||
|
|
||
| def index_all | ||
| @model_class.all.each do |member| | ||
| member.class.xapit_index_builder.add_document(member, true) | ||
| end | ||
| end | ||
| end | ||
| end | ||
| end | ||
|
|
||
| if defined?(Mongoid::Document) | ||
| Mongoid::Document::ClassMethods.send(:include, Xapit::Client::Membership::ClassMethods) | ||
| 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
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
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this can be moved to the initializer? (https://github.com/ryanb/xapit/blob/master/lib/xapit/client/railtie.rb#L9-11)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why? I want those methods available on sinatra too, that's not rails exclusive
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sounds good, then is a good idea move the AR one to active_record_adapter.rb
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
then is a good idea move the AR one to the adapter also :)