wheels 0.0.26 → 0.0.27

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. data/VERSION +1 -1
  2. data/app/models/ability.rb +21 -19
  3. data/wheels.gemspec +1 -1
  4. metadata +3 -3
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.26
1
+ 0.0.27
@@ -1,40 +1,42 @@
1
1
  class Ability
2
2
  include CanCan::Ability
3
+ def self.initializers
4
+ @initializers ||= []
5
+ end
6
+
7
+ def self.initializer(*method_names)
8
+ method_names.each{|t| initializers << t}
9
+ end
3
10
  initializer :init_wheels
4
11
 
5
12
  def initialize(user)
6
- initializers.each{|t| self.send(t, user)}
13
+ user ||= User.nobody
14
+ puts all_aces_for(user).map{|t| "#{t.resource_class_name} #{t.options.inspect}"}.join("\n")
15
+ self.class.initializers.each{|t| self.send(t, user)}
16
+ all_aces_for(user).each do |ace|
17
+ ace.configure(self)
18
+ end
19
+ end
20
+
21
+ def all_aces_for(user)
22
+ (user.access_control_entries + user.role.access_control_entries)
7
23
  end
8
24
 
9
25
  def init_wheels(user)
10
26
  can :read, :all
11
- return cannot :read, User unless user
12
27
  roles = Role.all
13
- user ||= User.new
14
28
  def roles.find_by_name(name); self.select{|t| t.name==name}[0]; end;
15
- case user.role_id
16
- when roles.find_by_name("Super")
29
+ case user.role.id
30
+ when roles.find_by_name("Super").id
17
31
  can :manage, :all
18
- when roles.find_by_name("Admin")
32
+ when roles.find_by_name("Admin").id
19
33
  can :manage, :all
20
- when roles.find_by_name("User")
34
+ when roles.find_by_name("User").id
21
35
  can :manage, Gallery, :user_id => user.id
22
36
  can :manage, Blog, :user_id => user.id
23
37
  can :edit, Profile, :user_id => user.id
24
38
  cannot :read, User
25
39
  end
26
- can :read, :all
27
40
  end
28
-
29
-
30
- def self.initializer(*method_names)
31
- method_names.each{|t| initializers << t}
32
- end
33
-
34
- def initializers
35
- @initializers ||= []
36
- end
37
-
38
-
39
41
  end
40
42
 
data/wheels.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{wheels}
8
- s.version = "0.0.26"
8
+ s.version = "0.0.27"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Tyler Gannon"]
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wheels
3
3
  version: !ruby/object:Gem::Version
4
- hash: 43
4
+ hash: 41
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 26
10
- version: 0.0.26
9
+ - 27
10
+ version: 0.0.27
11
11
  platform: ruby
12
12
  authors:
13
13
  - Tyler Gannon