Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
aefc2f8
commit 07b08d0
Showing
6 changed files
with
49 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
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,32 @@ | ||
module FortyFacets | ||
class ScopeFilterDefinition < FilterDefinition | ||
class ScopeFilter < Filter | ||
def active? | ||
value == '1' | ||
end | ||
|
||
def build_scope | ||
return Proc.new { |base| base } unless active? | ||
Proc.new { |base| base.send(definition.path.first) } | ||
end | ||
|
||
def remove | ||
new_params = search_instance.params || {} | ||
new_params.delete(definition.request_param) | ||
search_instance.class.new_unwrapped(new_params, search_instance.root) | ||
end | ||
|
||
def add | ||
new_params = search_instance.params || {} | ||
new_params[definition.request_param] = '1' | ||
search_instance.class.new_unwrapped(new_params, search_instance.root) | ||
end | ||
end | ||
|
||
def build_filter(search_instance, value) | ||
ScopeFilter.new(self, search_instance, value) | ||
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
module FortyFacets | ||
VERSION = "0.1.0" | ||
VERSION = "0.1.1" | ||
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