Project

scoped_id

0.0
No commit activity in last 3 years
No release in over 3 years
Generates scoped unique identifiers
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.5
>= 0
>= 0
>= 0

Runtime

>= 4.0.0
 Project Readme

scoped_id

Generates scoped unique identifiers.

Installation

Add scoped_id to your Gemfile:

gem 'scoped_id', '~> 0.0.2'

Usage

class Project < ActiveRecord::Base
  include ScopedId::Concern
  scoped_id :per_owner_id, scope: :owner_id
end

jacks_project = Project.create(owner_id: 1)
jacks_project.per_owner_id # => 1

johns_project = Project.create(owner_id: 2)
johns_project.per_owner_id # => 1

The scoped_id is generated in a before_create callback unless it has been manually set.

The scoped_id will be marked as readonly and will validate the uniqueness of its value.

Options

Scope (required)

The scope by which to determine the next identifier when creating a new object.

Contributing

  1. Fork it ( http://github.com/mbillard/scoped_id/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request