Class: Decidim::Accountability::ResultSerializer
- Inherits:
 - 
      Exporters::Serializer
      
        
- Object
 - Exporters::Serializer
 - Decidim::Accountability::ResultSerializer
 
 
- Includes:
 - ResourceHelper, TranslationsHelper
 
- Defined in:
 - lib/decidim/accountability/result_serializer.rb
 
Overview
This class serializes a Result so can be exported to CSV, JSON or other formats.
Instance Method Summary collapse
- 
  
    
      #initialize(result)  ⇒ ResultSerializer 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    
Public: Initializes the serializer with a result.
 - 
  
    
      #serialize  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Public: Exports a hash with the serialized data for this result.
 
Constructor Details
#initialize(result) ⇒ ResultSerializer
Public: Initializes the serializer with a result.
      12 13 14  | 
    
      # File 'lib/decidim/accountability/result_serializer.rb', line 12 def initialize(result) @result = result end  | 
  
Instance Method Details
#serialize ⇒ Object
Public: Exports a hash with the serialized data for this result.
      17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46  | 
    
      # File 'lib/decidim/accountability/result_serializer.rb', line 17 def serialize { id: result.id, category: { id: result.category.try(:id), name: result.category.try(:name) || empty_translatable }, scope: { id: result.scope.try(:id), name: result.scope.try(:name) || empty_translatable }, parent: { id: result.parent.try(:id) }, title: result.title, description: result.description, start_date: result.start_date, end_date: result.end_date, status: { id: result.status.try(:id), key: result.status.try(:key), name: result.status.try(:name) || empty_translatable }, progress: result.progress, created_at: result.created_at, url:, component: { id: component.id }, proposal_urls: proposals } end  |