Skip to content
Browse files

up to 0.1.1

  • Loading branch information...
1 parent 68548c6 commit fa8ca155acfd594441224a45d954fe9783c2e485 @randx committed
Showing with 26 additions and 14 deletions.
  1. +8 −0 CHANGELOG
  2. +7 −7 README.markdown
  3. +9 −5 lib/six.rb
  4. +2 −2 six.gemspec
View
8 CHANGELOG
@@ -0,0 +1,8 @@
+v 0.1.1
+ - 'add' - alias method for add_pack
+ - 'add!' - alias method for add_pack!
+ - 'remove' - alias method for remove_pack
+ - 'remove!' - alias method for remove_pack!
+ - 'reset' - alias method for reset_use
+ - 'exist?' - alias method for pack_exist?
+ - attr_accessor -> attr_reader for current_rule_pack, rules_packs
View
14 README.markdown
@@ -30,7 +30,7 @@
3. Add object with your rules to abilities
```ruby
- abilities.add_pack(:book, BookRules) # true
+ abilities.add(:book, BookRules) # true
```
4. Thats all. Now you can check abilites. In difference to CanCan it doesnt use current_user method. you manually pass object & subject.
@@ -71,7 +71,7 @@ end
abilites = Six.new
# Add rules to namespace ':book' & global namespace
-abilities.add_pack(:book, BookRules) # true
+abilities.add(:book, BookRules) # true
# thats all - now we can use it!
@@ -125,7 +125,7 @@ class BooksController < ApplicationController
protected
def add_abilities
- abilities.add_pack(:book, Book)
+ abilities.add(:book, Book)
end
def load_author
@@ -171,10 +171,10 @@ end
abilities = Six.new
# add packs
-abilities.add_pack(:book, BookRules) # true
-abilities.add_pack(:car, CarRules) # true
-abilities.add_pack(:ufo, nil) # false
-abilities.add_pack!(:ufo, nil) # raise Six::InvalidPackPassed
+abilities.add(:book, BookRules) # true
+abilities.add(:car, CarRules) # true
+abilities.add(:ufo, nil) # false
+abilities.add!(:ufo, nil) # raise Six::InvalidPackPassed
# use specific pack for rules
View
14 lib/six.rb
@@ -11,11 +11,12 @@ def message
end
end
- attr_accessor :rules_packs
- attr_accessor :current_rule_pack
+ attr_reader :rules_packs
+ attr_reader :current_rule_pack
- def rules_packs
- @rules_packs ||= {}
+ def initialize()
+ @rules_packs = {}
+ @current_rule_pack = nil
end
# Set current pack from stored packs by key
@@ -150,9 +151,12 @@ def raise_incorrect_pack_object
raise Six::InvalidPackPassed.new
end
+ # shotcuts for long methods
+
alias_method :add, :add_pack
alias_method :add!, :add_pack!
-
alias_method :remove, :remove_pack
alias_method :remove!, :remove_pack!
+ alias_method :reset, :reset_use
+ alias_method :exist?, :pack_exist?
end
View
4 six.gemspec
@@ -1,7 +1,7 @@
Gem::Specification.new do |s|
s.name = 'six'
- s.version = '0.1.0'
- s.date = '2011-08-20'
+ s.version = '0.1.1'
+ s.date = '2011-08-24'
s.summary = "six"
s.description = "Very simple authorization gem"
s.authors = ["Dmitriy Zaporozhets"]

0 comments on commit fa8ca15

Please sign in to comment.
Something went wrong with that request. Please try again.