README.md in auth_strategist-0.5.0 vs README.md in auth_strategist-0.6.0

- old
+ new

@@ -2,10 +2,11 @@ [codeclimate]: https://codeclimate.com/github/buszu/auth_strategist/ AuthStrategist ====== [![Code Climate](https://codeclimate.com/github/buszu/auth_strategist/badges/gpa.svg)](https://codeclimate.com/github/buszu/auth_strategist) +[![Gem Version](https://badge.fury.io/rb/auth_strategist.svg)](http://badge.fury.io/rb/auth_strategist) AuthStrategist is a simple gem to define and use authorization strategies. ## Installation @@ -38,58 +39,58 @@ c.strategies_path = 'lib/auth_strategist/strategies' # Register your strategies # Required for each strategy you have defined c.strategies do |s| - # E.g. PasswordStrategy will be available under :password key - s.password = PasswordStrategy + # E.g. OwnershipAuthStrategy will be available under :ownership key + s.ownership = OwnershipAuthStrategy end end ``` ## Usage ### Defining a Strategy * Define a strategy ```ruby -class PasswordStrategy +class OwnershipAuthStrategy include AuthStrategist::StrategyInterface - define_components :user, :password + define_components :user, :item def authorize! - raise StandardError unless user.password == password + raise unauthorized if item.user_id != user.id end end ``` * Register it ```ruby AuthStrategist.strategies do |s| - s.password = PasswordStrategy + s.ownership = OwnershipAuthStrategy end ``` or ```ruby AuthStrategist.configure do |c| c.strategies do |s| - s.password = PasswordStrategy + s.ownership = OwnershipAuthStrategy end end ``` ### Using strategies * Using strategy by calling authorization Service Object ```ruby -AuthStrategist::Authorize.call strategy: :password, +AuthStrategist::Authorize.call strategy: :ownership, user: current_user, - password: password + item: book ``` * Using strategy with authorize! method ```ruby class SomethingsController < ApplicationController include AuthStrategist::Authorization def show - authorize! strategy: :password, user: current_user, password: password + authorize! strategy: :ownership, user: current_user, item: book end end ``` ## Contributing