Class: RailsAdminImport::Formats::FileImporter
- Inherits:
 - 
      Object
      
        
- Object
 - RailsAdminImport::Formats::FileImporter
 
 
- Defined in:
 - lib/rails_admin_import/formats/file_importer.rb
 
Direct Known Subclasses
Instance Attribute Summary collapse
- 
  
    
      #error  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    
Returns the value of attribute error.
 - 
  
    
      #filename  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    
Returns the value of attribute filename.
 - 
  
    
      #import_model  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    
Returns the value of attribute import_model.
 
Instance Method Summary collapse
- #each(&block) ⇒ Object
 - 
  
    
      #initialize(import_model, params)  ⇒ FileImporter 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    
A new instance of FileImporter.
 - #valid? ⇒ Boolean
 
Constructor Details
#initialize(import_model, params) ⇒ FileImporter
Returns a new instance of FileImporter.
      4 5 6 7 8 9  | 
    
      # File 'lib/rails_admin_import/formats/file_importer.rb', line 4 def initialize(import_model, params) if params.has_key?(:file) @filename = params[:file].tempfile end @import_model = import_model end  | 
  
Instance Attribute Details
#error ⇒ Object (readonly)
Returns the value of attribute error.
      11 12 13  | 
    
      # File 'lib/rails_admin_import/formats/file_importer.rb', line 11 def error @error end  | 
  
#filename ⇒ Object (readonly)
Returns the value of attribute filename.
      11 12 13  | 
    
      # File 'lib/rails_admin_import/formats/file_importer.rb', line 11 def filename @filename end  | 
  
#import_model ⇒ Object (readonly)
Returns the value of attribute import_model.
      11 12 13  | 
    
      # File 'lib/rails_admin_import/formats/file_importer.rb', line 11 def import_model @import_model end  | 
  
Instance Method Details
#each(&block) ⇒ Object
      22 23 24 25 26 27 28 29 30  | 
    
      # File 'lib/rails_admin_import/formats/file_importer.rb', line 22 def each(&block) return enum_for(:each) unless block_given? if RailsAdminImport.config.logging && filename copy_uploaded_file_to_log_dir end each_record(&block) end  | 
  
#valid? ⇒ Boolean
      13 14 15 16 17 18 19 20  | 
    
      # File 'lib/rails_admin_import/formats/file_importer.rb', line 13 def valid? if filename.nil? @error = I18n.t("admin.import.missing_file") false else true end end  |