Socket
Book a DemoInstallSign in
Socket

has_sunspot_scope

Package Overview
Dependencies
Maintainers
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

has_sunspot_scope

0.1.2
bundlerRubygems
Version published
Maintainers
2
Created
Source

== 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

Package last updated on 08 Oct 2010

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.