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.
- data/lib/active_importer/base.rb +9 -8
- data/lib/active_importer/version.rb +1 -1
- data/spec/stubs/employee.rb +1 -1
- metadata +3 -3
data/lib/active_importer/base.rb
CHANGED
@@ -7,14 +7,15 @@ module ActiveImporter
|
|
7
7
|
# DSL and class variables
|
8
8
|
#
|
9
9
|
|
10
|
-
@
|
10
|
+
@abort_message = nil
|
11
11
|
|
12
|
-
def abort!
|
13
|
-
@
|
12
|
+
def abort!(message)
|
13
|
+
@abort_message = message
|
14
14
|
end
|
15
15
|
|
16
|
-
|
17
|
-
|
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
|
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
|
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
|
data/spec/stubs/employee.rb
CHANGED
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.
|
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:
|
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:
|
124
|
+
hash: 3645783224165529099
|
125
125
|
requirements: []
|
126
126
|
rubyforge_project:
|
127
127
|
rubygems_version: 1.8.23
|