active_importer 0.2.3 → 0.2.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -7,14 +7,15 @@ module ActiveImporter
7
7
  # DSL and class variables
8
8
  #
9
9
 
10
- @aborted = false
10
+ @abort_message = nil
11
11
 
12
- def abort!
13
- @aborted = true
12
+ def abort!(message)
13
+ @abort_message = message
14
14
  end
15
15
 
16
- @model_class = nil
17
- @columns = {}
16
+ def aborted?
17
+ !!@abort_message
18
+ end
18
19
 
19
20
  def self.imports(klass)
20
21
  @model_class = klass
@@ -158,8 +159,8 @@ module ActiveImporter
158
159
  next
159
160
  end
160
161
  import_row
161
- if @aborted
162
- fire_event :import_aborted
162
+ if aborted?
163
+ fire_event :import_aborted, @abort_message
163
164
  break
164
165
  end
165
166
  end
@@ -220,7 +221,7 @@ module ActiveImporter
220
221
  begin
221
222
  @model = fetch_model
222
223
  build_model
223
- model.save! unless @aborted
224
+ model.save! unless aborted?
224
225
  rescue => e
225
226
  @row_errors << { row_index: row_index, error_message: e.message }
226
227
  fire_event :row_error, e
@@ -1,3 +1,3 @@
1
1
  module ActiveImporter
2
- VERSION = "0.2.3"
2
+ VERSION = "0.2.4"
3
3
  end
@@ -29,7 +29,7 @@ class EmployeeImporter < EmployeeBaseImporter
29
29
  end
30
30
 
31
31
  on :row_processing do
32
- abort! if row['Name'] == 'Abort'
32
+ abort!('Row cannot be processed') if row['Name'] == 'Abort'
33
33
  end
34
34
 
35
35
  skip_rows_if do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_importer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.2.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -112,7 +112,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
112
112
  version: '0'
113
113
  segments:
114
114
  - 0
115
- hash: -1273178247667162898
115
+ hash: 3645783224165529099
116
116
  required_rubygems_version: !ruby/object:Gem::Requirement
117
117
  none: false
118
118
  requirements:
@@ -121,7 +121,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
121
121
  version: '0'
122
122
  segments:
123
123
  - 0
124
- hash: -1273178247667162898
124
+ hash: 3645783224165529099
125
125
  requirements: []
126
126
  rubyforge_project:
127
127
  rubygems_version: 1.8.23