Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

acts_as_list_neo4j

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

acts_as_list_neo4j

  • 0.0.2
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

Neo4j Acts as list

This is a port of the classic +acts_as_list+ to Neo4j.

This acts_as extension provides the capabilities for sorting and reordering a number of objects in a list. If you do not specify custom position +column+ in the options, a key named +position+ will be used automatically.

Installation

gem install acts_as_list_neo4j

Usage

WARNING: This gem still requires refactoring. Currently, it only works OK for small workloads.

See the /specs folder specs that demontrate the API. Usage examples are located in the /examples folder.

To make a class Act as List, simply do:

  include ActsAsList::Neo4j   

And it will automatically set up a property and call acts_as_list with that property. By default the property name is :position. You can change the defaut position_column name used: ActsAsList::Neo4j.default_position_column = :pos. For this class variable to be effetive, it should be set before calling include ActsAsList::Neo4j.

Example

  class Item
    include Neo4j::ActiveNode
    include ActsAsList::Neo4j

    property :text
  end

  %w{'clean', 'wash', 'repair'}.each do |text|
    Item.new(text: text)
  end

  Item.first.move(:bottom)
  Item.last.move(:higher)

Overriding defaults

By default, when including ActsAsList::Neo4j, the property is set to :position and the acts_as_list column to :position. To change this:

  include ActsAsList::Mongoid   
  
  property :pos, type: Integer
  acts_as_list column: :pos

move API

item.move(:highest)          # moves to top of list.
item.move(:lowest)           # moves to bottom of list.
item.move(:top)              # moves to top of list.
item.move(:bottom)           # moves to bottom of list.
item.move(:up)               # moves one up (:higher and :up is the same) within the scope.
item.move(:down)             # moves one up (:lower and :down is the same) within the scope.
item.move(to: position)   # moves item to a specific position.
item.move(above: other)   # moves item above the other item.*
item.move(below: other)

Running the specs

bundle exec rspec spec

FAQs

Package last updated on 08 Jul 2015

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