batch_insert 0.1 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +7 -12
- data/Rakefile +1 -1
- data/init.rb +3 -1
- data/rails/init.rb +3 -0
- metadata +4 -2
data/README.md
CHANGED
@@ -10,20 +10,17 @@ by ActiveRecord, but will not return a saved object to the caller.
|
|
10
10
|
Example
|
11
11
|
=======
|
12
12
|
|
13
|
-
Previously
|
14
|
-
-----------
|
13
|
+
**Previously:**
|
15
14
|
|
16
15
|
100.times { ModelClass.create! :name => 'Test', :description => 'An example object being created.' }
|
17
16
|
|
18
|
-
Now
|
19
|
-
----
|
17
|
+
**Now:**
|
20
18
|
|
21
19
|
ModelClass.batch_insert do
|
22
20
|
100.times { ModelClass.insert :name => 'Test', :description => 'An example object being created.' }
|
23
21
|
end
|
24
22
|
|
25
|
-
Batch insertions return the same result as new()
|
26
|
-
------------------------------------------------
|
23
|
+
**Batch insertions return the same result as new()**
|
27
24
|
|
28
25
|
ModelClass.batch_insert do
|
29
26
|
args = {:name => 'Test', :description => 'An example object being created.'}
|
@@ -33,21 +30,19 @@ Batch insertions return the same result as new()
|
|
33
30
|
ModelClass.insert(args).id # nil
|
34
31
|
end # The insertion is done at this point in the code.
|
35
32
|
|
36
|
-
Invalid objects will immediately cause an exception
|
37
|
-
---------------------------------------------------
|
33
|
+
**Invalid objects will immediately cause an exception**
|
38
34
|
|
39
35
|
ModelClass.batch_insert do
|
40
36
|
invalid_args = {}
|
41
37
|
ModelClass.insert(invalid_args) # Exception!
|
42
38
|
end
|
43
39
|
|
44
|
-
Constraint violations will cause an exception when the batch is inserted
|
45
|
-
------------------------------------------------------------------------
|
40
|
+
**Constraint violations will cause an exception when the batch is inserted**
|
46
41
|
|
47
42
|
ModelClass.batch_insert do
|
48
43
|
conflict = {:unique_value => 'Collide!'}
|
49
|
-
ModelClass.insert(
|
50
|
-
ModelClass.insert(
|
44
|
+
ModelClass.insert(conflict)
|
45
|
+
ModelClass.insert(conflict)
|
51
46
|
end # Exception!
|
52
47
|
|
53
48
|
Copyright (c) 2010 Shaun Mangelsdorf, released under the MIT license
|
data/Rakefile
CHANGED
data/init.rb
CHANGED
data/rails/init.rb
ADDED
metadata
CHANGED
@@ -5,7 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 1
|
8
|
-
|
8
|
+
- 1
|
9
|
+
version: 0.1.1
|
9
10
|
platform: ruby
|
10
11
|
authors:
|
11
12
|
- Shaun Mangelsdorf
|
@@ -13,7 +14,7 @@ autorequire:
|
|
13
14
|
bindir: bin
|
14
15
|
cert_chain: []
|
15
16
|
|
16
|
-
date: 2010-11-
|
17
|
+
date: 2010-11-11 00:00:00 +10:00
|
17
18
|
default_executable:
|
18
19
|
dependencies: []
|
19
20
|
|
@@ -36,6 +37,7 @@ files:
|
|
36
37
|
- install.rb
|
37
38
|
- lib/batch_insert.rb
|
38
39
|
- lib/tasks/batch_insert.rake
|
40
|
+
- rails/init.rb
|
39
41
|
has_rdoc: true
|
40
42
|
homepage: http://smangelsdorf.github.com
|
41
43
|
licenses: []
|