
Security News
Astral Launches pyx: A Python-Native Package Registry
Astral unveils pyx, a Python-native package registry in beta, designed to speed installs, enhance security, and integrate deeply with uv.
== HasScope
== Block usage
This fork works only for sunspot_rails and i have only used the block variants
class GraduationsController < ApplicationController
has_scope :query do |controller, search, value|
search.keywords(value)
end
has_scope :category do |controller, search, value|
search.with(:category_id, value)
end
def index
@search = Graduation.search do |search|
apply_scopes(search)
search.facet(:category_id, :exclude => scope_return_values[:category] #multi-facet search
end
@graduations = @search.results
end
end
You can retrieve all the scopes applied in one action with current_scopes method.
== Installation
HasScope is available as gem on Gemcutter, so just run the following:
sudo gem install has_scope
If you want it as plugin, just do:
script/plugin install git://github.com/plataformatec/has_scope.git
== Options
HasScope supports several options:
:type - Checks the type of the parameter sent. If set to :boolean it just calls the named scope, without any argument. By default, it does not allow hashes or arrays to be given, except if type :hash or :array are set.
:only - In which actions the scope is applied.
:except - In which actions the scope is not applied.
:as - The key in the params hash expected to find the scope. Defaults to the scope name.
:using - The subkeys to be used as args when type is a hash.
:if - Specifies a method, proc or string to call to determine if the scope should apply.
:unless - Specifies a method, proc or string to call to determine if the scope should NOT apply.
:default - Default value for the scope. Whenever supplied the scope is always called.
:allow_blank - Blank values are not sent to scopes by default. Set to true to overwrite.
== Bugs and Feedback
If you discover any bugs or want to drop a line, feel free to create an issue on GitHub.
http://github.com/plataformatec/has_scope/issues
MIT License. Copyright 2009 Plataforma Tecnologia. http://blog.plataformatec.com.br
FAQs
Unknown package
We found that has_sunspot_scope demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Astral unveils pyx, a Python-native package registry in beta, designed to speed installs, enhance security, and integrate deeply with uv.
Security News
The Latio podcast explores how static and runtime reachability help teams prioritize exploitable vulnerabilities and streamline AppSec workflows.
Security News
The latest Opengrep releases add Apex scanning, precision rule tuning, and performance gains for open source static code analysis.