<commit_before>{<img src="https://badge.fury.io/rb/abilities.png" alt="Gem Version" />}[http://badge.fury.io/rb/abilities] {<img src="https://codeclimate.com/github/museways/abilities.png" />}[https://codeclimate.com/github/museways/abilities] {<img src="https://travis-ci.org/museways/abilities.png?branch=master" alt="Build Status" />}[https://travis-ci.org/museways/abilities]

= Abilities

Minimalistic authorization inspired in cancan for rails.

= Install

Put this line in your Gemfile:
  gem 'abilities'

Then bundle:
  $ bundle

= Configuration

Generate the abilities initializer:
  bundle exec rails g abilities:install

Ensure there is a current_user helper available in your controllers and views:
  class ApplicationController < ActionController::Base
    helper :current_user
    def current_user
      @current_user ||= User.find_by(id: session[:user_id])
    end
  end

NOTE: The gem will look for a User model and include Abilities::Concern into it.

= Usage

== Defining

All the abilities are defined in config/initializers/abilities.rb by can and cannot methods:
  Abilities.define do
    can :create, Post
    cannot :destroy, User unless admin?
    can :edit, Post do |post|
      post.user == self
    end
    can :manage, :user
    can :touch, :all
  end

If you want to load the abilities from the database you may do something like this:
  Abilities.define do
    permissions.each do |permission|
      can premissions.action, permissions.subject
    end
  end

NOTE: Any method besides can and cannot references the current_user.
<commit_msg>Fix readme typo<commit_after>{<img src="https://badge.fury.io/rb/abilities.png" alt="Gem Version" />}[http://badge.fury.io/rb/abilities] {<img src="https://codeclimate.com/github/museways/abilities.png" />}[https://codeclimate.com/github/museways/abilities] {<img src="https://travis-ci.org/museways/abilities.png?branch=master" alt="Build Status" />}[https://travis-ci.org/museways/abilities]

= Abilities

Minimalistic authorization inspired in cancan for rails.

= Install

Put this line in your Gemfile:
  gem 'abilities'

Then bundle:
  $ bundle

= Configuration

Generate the abilities initializer:
  bundle exec rails g abilities:install

Ensure there is a current_user helper available in your controllers and views:
  class ApplicationController < ActionController::Base
    helper :current_user
    def current_user
      @current_user ||= User.find_by(id: session[:user_id])
    end
  end

NOTE: The gem will look for a User model and include Abilities::Concern into it.

= Usage

== Defining

All the abilities are defined in config/initializers/abilities.rb by can and cannot methods:
  Abilities.define do
    can :create, Post
    cannot :destroy, User unless admin?
    can :edit, Post do |post|
      post.user == self
    end
    can :manage, User
    can :touch, :all
  end

If you want to load the abilities from the database you may do something like this:
  Abilities.define do
    permissions.each do |permission|
      can premissions.action, permissions.subject
    end
  end

NOTE: Any method besides can and cannot references the current_user.

{'fraction_non_alphanumeric': 0.0971028334925183, 'fraction_numerical': 0.0, 'mean_word_length': 3.9793977812995247, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 9, 'https://': 10, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4684277', 'n_tokens_mistral': 946, 'n_tokens_neox': 935, 'n_words': 320}