README.md in authoraise-0.1.2 vs README.md in authoraise-0.1.3
- old
+ new
@@ -4,11 +4,11 @@
So instead of writing boolean expressions like this.
~~~ruby
options[:post] &&
- (options[:post].publised? || (options[:post].user == options[:user]))
+ (options[:post].published? || (options[:post].user == options[:user]))
~~~
You would write them like this.
~~~ruby
@@ -16,10 +16,19 @@
policy.allow { |post| post.published? }
policy.allow { |post, user| post.user == user }
policy.authorize(options)
~~~
-Or like this.
+Or like this (my personal favorite).
+
+~~~ruby
+ policy = Authoraise::Policy.new do |p|
+ p.allow { |post| post.published? }
+ p.allow { |post, user| post.user == user }
+ end
+~~~
+
+Or like this, where declaration and authorization both happen inline.
~~~ruby
authorize(options) do |policy|
policy.allow { |post| post.published? }
policy.allow { |post, user| post.user == user }