Class: Decidim::Elections::TrusteeZone::UpdateTrustee
- Inherits:
 - 
      Command
      
        
- Object
 - Command
 - Decidim::Elections::TrusteeZone::UpdateTrustee
 
 
- Defined in:
 - app/commands/decidim/elections/trustee_zone/update_trustee.rb
 
Overview
This command allows the user to update their trustee information
Instance Method Summary collapse
- 
  
    
      #call  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Update the trustee if valid.
 - 
  
    
      #initialize(form)  ⇒ UpdateTrustee 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    
Public: Initializes the command.
 
Constructor Details
#initialize(form) ⇒ UpdateTrustee
Public: Initializes the command.
form - A form with the new trustee information
      11 12 13  | 
    
      # File 'app/commands/decidim/elections/trustee_zone/update_trustee.rb', line 11 def initialize(form) @form = form end  | 
  
Instance Method Details
#call ⇒ Object
Update the trustee if valid.
Broadcasts :ok if successful, :invalid otherwise.
      18 19 20 21 22 23 24 25 26 27  | 
    
      # File 'app/commands/decidim/elections/trustee_zone/update_trustee.rb', line 18 def call return broadcast(:invalid) if form.invalid? update_trustee! broadcast(:ok, trustee) rescue ActiveRecord::RecordNotUnique form.errors.add(:name, :taken) broadcast(:invalid) end  |