-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds Mongoid backend for UntiedConsumerSync.
- Loading branch information
1 parent
f2fc4bc
commit 1aa245a
Showing
3 changed files
with
35 additions
and
1 deletion.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
require "untied-consumer-sync" | ||
|
||
module Untied | ||
module Consumer | ||
module Sync | ||
module Backend | ||
module Mongoid | ||
class ModelHelper | ||
include Sync::Backend::Base | ||
|
||
# Public: Finds the instance by the id. | ||
# | ||
# id - Integer that identifies the objects according to config file. | ||
# | ||
# Returns the instance (if exists in the database) or nil. | ||
def find(id) | ||
# Used where so no exception will be raised if the instance | ||
# does not exist. | ||
@model.unscoped.where(@model_data['mappings']['id'].to_sym => id).first | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
require 'spec_helper' | ||
|
||
module Untied::Consumer::Sync::Backend::Mongoid | ||
describe ModelHelper do | ||
it_behaves_like 'a untied-consumer-sync backend' | ||
end | ||
end |