New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

scoped_traversal

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

scoped_traversal

  • 0.1
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

Scoped Traversal

A simple way to define next and previous relationships in an ActiveRecord model.

For example, if you have a list of articles, and you want to be able to traverse them with article.next and article.previous.

Installation

Add to your Gemfile and run the bundle command to install it.

gem "scoped_traversal"

Requires Ruby 1.9.2 or later.

Usage

In your model, call rank_by and pass in a column name.

class User < ActiveRecord::Base
	traverse_by :score
end

You can then traverse them with the following methods:

@user.next
@user.previous

Namespaces

You can also add an optional namespace, like so:

class User < ActiveRecord::Base
   traverse_by :score, :namespace => true
   traverse_by :created_at, :namespace => :oldest
end

You can then traverse them with the following methods:

@user.next_score
@user.previous_score
   
@user.next_oldest
@user.previous_oldest

Development

Questions or problems? Please post them on the issue tracker. You can contribute changes by forking the project and submitting a pull request. You can ensure the tests passing by running bundle and rake.

This gem is created by Wil Gieseler and is under the MIT License.

FAQs

Package last updated on 21 Jan 2012

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

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc