No commit activity in last 3 years
No release in over 3 years
Restrictions registration for application context
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

 Project Readme

Spine::Restrictions

Gem Version Dependency Status Test Coverage Code Climate security Inline docs Codeship Status for rspine/restrictions

Restrictions registration for application context.

Installation

To install it, add the gem to your Gemfile:

gem 'spine-restrictions'

Then run bundle. If you're not using Bundler, just gem install spine-restrictions.

Usage

# Restriction can be module or class, which defines `restricted?` method based
# on context.
class UserSuspensionRestriction
  def restricted?(context)
    !!context.subject.suspended_at
  end
end

restrictions = Spine::Restrictions::Collection.new
restrictions.register(UserSuspensionRestriction)
  .restrict(:write, :all)
  .restrict(:update, :all)
  .restrict(:delete, :all)
  .except(:all, :billing)

restrictions.restricted?(context, :write, :tasks)
# => <UserSuspensionRestriction:0x007f8e51ad7960>