role_authorization 0.3.3 → 0.3.4
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.
| 
         @@ -8,7 +8,7 @@ RoleAuthorization::Rules.define :role do 
     | 
|
| 
       8 
8 
     | 
    
         
             
              else
         
     | 
| 
       9 
9 
     | 
    
         
             
                scope = if options[:scope]
         
     | 
| 
       10 
10 
     | 
    
         
             
                          if options[:scope].is_a?(Proc)
         
     | 
| 
       11 
     | 
    
         
            -
                            instance_eval(&options[:scope])
         
     | 
| 
      
 11 
     | 
    
         
            +
                            controller_instance.instance_eval(&options[:scope])
         
     | 
| 
       12 
12 
     | 
    
         
             
                          else
         
     | 
| 
       13 
13 
     | 
    
         
             
                            options[:scope]
         
     | 
| 
       14 
14 
     | 
    
         
             
                          end
         
     | 
| 
         @@ -21,18 +21,22 @@ RoleAuthorization::Rules.define :role do 
     | 
|
| 
       21 
21 
     | 
    
         
             
            end
         
     | 
| 
       22 
22 
     | 
    
         | 
| 
       23 
23 
     | 
    
         
             
            RoleAuthorization::Rules.define :user do
         
     | 
| 
       24 
     | 
    
         
            -
               
     | 
| 
       25 
     | 
    
         
            -
             
     | 
| 
       26 
     | 
    
         
            -
              if resource.nil?
         
     | 
| 
      
 24 
     | 
    
         
            +
              if controller_instance.current_user.blank?
         
     | 
| 
       27 
25 
     | 
    
         
             
                false
         
     | 
| 
       28 
26 
     | 
    
         
             
              else
         
     | 
| 
       29 
     | 
    
         
            -
                 
     | 
| 
      
 27 
     | 
    
         
            +
                if options[:resource]
         
     | 
| 
      
 28 
     | 
    
         
            +
                  check_method = options[:check] || :id
         
     | 
| 
      
 29 
     | 
    
         
            +
                  resource_instance = controller_instance.instance_eval(&options[:resource])
         
     | 
| 
      
 30 
     | 
    
         
            +
                  controller_instance.current_user.id == resource_instance.try(check_method)
         
     | 
| 
      
 31 
     | 
    
         
            +
                else
         
     | 
| 
      
 32 
     | 
    
         
            +
                  false
         
     | 
| 
      
 33 
     | 
    
         
            +
                end
         
     | 
| 
       30 
34 
     | 
    
         
             
              end
         
     | 
| 
       31 
35 
     | 
    
         
             
            end
         
     | 
| 
       32 
36 
     | 
    
         | 
| 
       33 
37 
     | 
    
         
             
            RoleAuthorization::Rules.define :custom do
         
     | 
| 
       34 
38 
     | 
    
         
             
              unless options[:block].nil?
         
     | 
| 
       35 
     | 
    
         
            -
                true if options[:block] 
     | 
| 
      
 39 
     | 
    
         
            +
                true if controller_instance.instance_eval(&options[:block]) == true
         
     | 
| 
       36 
40 
     | 
    
         
             
              else
         
     | 
| 
       37 
41 
     | 
    
         
             
                false
         
     | 
| 
       38 
42 
     | 
    
         
             
              end
         
     |