racl 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/lib/racl.rb +21 -5
  2. data/lib/racl/version.rb +1 -1
  3. metadata +2 -2
@@ -1,14 +1,30 @@
1
1
  module Racl
2
2
  module ClassMethods
3
-
3
+ #
4
+ # Hooks the Racl into the controller
5
+ #
6
+ def protect_with_racl
7
+ before_filter :racl_check
8
+ end
4
9
  end
5
10
 
6
11
  module InstanceMethods
7
-
12
+ #
13
+ # Checks permissions for a specific action on a specific model
14
+ # Return true if no acl_model was defined in the acl_models table or
15
+ # if the user has the privilege on the given model_name
16
+ #
17
+ def can privilege, model_name
18
+ return false unless logged_in?
19
+ access = true
20
+ privilege = current_user.privileges.find(:model_name => model_name.to_s, :privilege => privilege.to_s)
21
+ access = true if privilege
22
+ access
23
+ end
8
24
  end
9
25
 
10
- def self.included(receiver)
11
- receiver.extend ClassMethods
12
- receiver.send :include, InstanceMethods
26
+ def self.included(controller)
27
+ controller.extend ClassMethods
28
+ controller.send :include, InstanceMethods
13
29
  end
14
30
  end
@@ -1,3 +1,3 @@
1
1
  module Racl
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: racl
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.1.1
5
+ version: 0.1.2
6
6
  platform: ruby
7
7
  authors:
8
8
  - Emil Kampp
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-05-12 00:00:00 Z
13
+ date: 2011-05-13 00:00:00 Z
14
14
  dependencies: []
15
15
 
16
16
  description: This gem will give you a musch smoother access to different methods both in the controller and view layer.