Class: Decidim::ActionAuthorizer::AuthorizationStatus
- Inherits:
 - 
      Object
      
        
- Object
 - Decidim::ActionAuthorizer::AuthorizationStatus
 
 
- Defined in:
 - app/services/decidim/action_authorizer.rb
 
Instance Attribute Summary collapse
- 
  
    
      #code  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    
Returns the value of attribute code.
 - 
  
    
      #data  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    
Returns the value of attribute data.
 
Instance Method Summary collapse
- #current_path(redirect_url: nil) ⇒ Object
 - #handler_name ⇒ Object
 - 
  
    
      #initialize(code, authorization_handler, data)  ⇒ AuthorizationStatus 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    
A new instance of AuthorizationStatus.
 - #ok? ⇒ Boolean
 - #pending? ⇒ Boolean
 - #unauthorized? ⇒ Boolean
 
Constructor Details
#initialize(code, authorization_handler, data) ⇒ AuthorizationStatus
Returns a new instance of AuthorizationStatus.
      58 59 60 61 62  | 
    
      # File 'app/services/decidim/action_authorizer.rb', line 58 def initialize(code, , data) @code = code.to_sym @authorization_handler = @data = data.symbolize_keys end  | 
  
Instance Attribute Details
#code ⇒ Object (readonly)
Returns the value of attribute code.
      56 57 58  | 
    
      # File 'app/services/decidim/action_authorizer.rb', line 56 def code @code end  | 
  
#data ⇒ Object (readonly)
Returns the value of attribute data.
      56 57 58  | 
    
      # File 'app/services/decidim/action_authorizer.rb', line 56 def data @data end  | 
  
Instance Method Details
#current_path(redirect_url: nil) ⇒ Object
      64 65 66 67 68 69 70 71 72  | 
    
      # File 'app/services/decidim/action_authorizer.rb', line 64 def current_path(redirect_url: nil) return unless @authorization_handler if pending? @authorization_handler.(redirect_url:) else @authorization_handler.root_path(redirect_url:) end end  | 
  
#handler_name ⇒ Object
      74 75 76 77 78  | 
    
      # File 'app/services/decidim/action_authorizer.rb', line 74 def handler_name return unless @authorization_handler @authorization_handler.key end  | 
  
#ok? ⇒ Boolean
      80 81 82  | 
    
      # File 'app/services/decidim/action_authorizer.rb', line 80 def ok? @code == :ok end  | 
  
#pending? ⇒ Boolean
      84 85 86  | 
    
      # File 'app/services/decidim/action_authorizer.rb', line 84 def pending? @code == :pending end  | 
  
#unauthorized? ⇒ Boolean
      88 89 90  | 
    
      # File 'app/services/decidim/action_authorizer.rb', line 88 def @code == :unauthorized end  |