-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move options hash key normalization to separate file.
- Loading branch information
1 parent
3a35c38
commit dc8d681
Showing
4 changed files
with
53 additions
and
27 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
module Plucky | ||
module Normalizers | ||
class OptionsHashKey | ||
|
||
NormalizedKeys = { | ||
:order => :sort, | ||
:select => :fields, | ||
:offset => :skip, | ||
:id => :_id, | ||
} | ||
|
||
def call(key) | ||
NormalizedKeys.fetch key.to_sym, key | ||
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
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,23 @@ | ||
require 'helper' | ||
|
||
describe Plucky::Normalizers::OptionsHashKey do | ||
subject { | ||
described_class.new | ||
} | ||
|
||
it "changes order to sort" do | ||
subject.call(:order).should eq(:sort) | ||
end | ||
|
||
it "changes select to fields" do | ||
subject.call(:select).should eq(:fields) | ||
end | ||
|
||
it "changes offset to skip" do | ||
subject.call(:offset).should eq(:skip) | ||
end | ||
|
||
it "changes id to _id" do | ||
subject.call(:id).should eq(:_id) | ||
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