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.
- data/VERSION +1 -1
- data/app/models/ability.rb +21 -19
- data/wheels.gemspec +1 -1
- metadata +3 -3
    
        data/VERSION
    CHANGED
    
    | @@ -1 +1 @@ | |
| 1 | 
            -
            0.0. | 
| 1 | 
            +
            0.0.27
         | 
    
        data/app/models/ability.rb
    CHANGED
    
    | @@ -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 | 
            -
                 | 
| 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. | 
| 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
    
    
    
        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:  | 
| 4 | 
            +
              hash: 41
         | 
| 5 5 | 
             
              prerelease: false
         | 
| 6 6 | 
             
              segments: 
         | 
| 7 7 | 
             
              - 0
         | 
| 8 8 | 
             
              - 0
         | 
| 9 | 
            -
              -  | 
| 10 | 
            -
              version: 0.0. | 
| 9 | 
            +
              - 27
         | 
| 10 | 
            +
              version: 0.0.27
         | 
| 11 11 | 
             
            platform: ruby
         | 
| 12 12 | 
             
            authors: 
         | 
| 13 13 | 
             
            - Tyler Gannon
         |