Class: MrCommon::PreRegistrationImporter
- Inherits:
-
Object
- Object
- MrCommon::PreRegistrationImporter
- Defined in:
- app/models/mr_common/pre_registration_importer.rb
Overview
Imports PreRegistration records from a CSV file that looks like:
first_name, last_name, email
John, Smith, [email protected]
Jane, Doe, [email protected]
,,[email protected]
Name,Only,
Defined Under Namespace
Classes: ResultStruct, RowStruct
Instance Attribute Summary collapse
-
#csv ⇒ Object
readonly
Returns the value of attribute csv.
-
#current_row ⇒ Object
readonly
Returns the value of attribute current_row.
-
#result ⇒ Object
readonly
Returns the value of attribute result.
Instance Method Summary collapse
-
#import ⇒ Object
Attempts to create PreRegistration records for each row in the CSV recording the number of created and skipped records in the process.
-
#initialize(csv) ⇒ PreRegistrationImporter
constructor
A new instance of PreRegistrationImporter.
Constructor Details
#initialize(csv) ⇒ PreRegistrationImporter
Returns a new instance of PreRegistrationImporter.
27 28 29 30 31 |
# File 'app/models/mr_common/pre_registration_importer.rb', line 27 def initialize(csv) @csv = csv @created = 0 @skipped = 0 end |
Instance Attribute Details
#csv ⇒ Object (readonly)
Returns the value of attribute csv.
24 25 26 |
# File 'app/models/mr_common/pre_registration_importer.rb', line 24 def csv @csv end |
#current_row ⇒ Object (readonly)
Returns the value of attribute current_row.
24 25 26 |
# File 'app/models/mr_common/pre_registration_importer.rb', line 24 def current_row @current_row end |
#result ⇒ Object (readonly)
Returns the value of attribute result.
24 25 26 |
# File 'app/models/mr_common/pre_registration_importer.rb', line 24 def result @result end |
Instance Method Details
#import ⇒ Object
Attempts to create PreRegistration records for each row in the CSV recording the number of created and skipped records in the process.
The result is memoized to prevent double imports.
39 40 41 |
# File 'app/models/mr_common/pre_registration_importer.rb', line 39 def import @result ||= perform_import end |