deferring 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d3b21ec82ca5a7c3f62259abc852c195553ebed1
|
4
|
+
data.tar.gz: b2a2819985c21278781a1ef8fd1d6b97fef61945
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8181bd48cfbef4cc775fcb9a58a24ae60ead0555377fe87551e0629078453d4d55b03e8e7f04cafe3820c4839bfd22cca24dc6cee6921c1e121d5598971aaf81
|
7
|
+
data.tar.gz: 0b2c33f182e9ce5e2d1b66ecf42cb16abc2f4b92f1bcc5afbbb173f2b8dd919c71876cc66305d3f3d280340351e18993af686c6f5b846f5d3128ac1a1a0d9432
|
@@ -36,7 +36,7 @@ module Deferring
|
|
36
36
|
|
37
37
|
# Delegates methods from Ruby's Array module to the object in the deferred
|
38
38
|
# association.
|
39
|
-
delegate :[], :clear, :reject, :reject!, :flatten, :flatten!, :sort!,
|
39
|
+
delegate :[]=, :[], :clear, :reject, :reject!, :flatten, :flatten!, :sort!,
|
40
40
|
:sort_by!, :empty?, :size, :length, to: :objects
|
41
41
|
|
42
42
|
# Delegates Ruby's Enumerable#find method to the original association.
|
@@ -111,25 +111,27 @@ module Deferring
|
|
111
111
|
end
|
112
112
|
|
113
113
|
def build(*args, &block)
|
114
|
-
association.build(*args, &block).tap do |
|
115
|
-
|
114
|
+
association.build(*args, &block).tap do |record|
|
115
|
+
run_deferring_callbacks(:link, record) do
|
116
|
+
objects.push(record)
|
116
117
|
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
118
|
+
# Remove the newly build record from the original association. If we
|
119
|
+
# didn't do this, the new record would be saved to the database when
|
120
|
+
# saving the parent object (and not after, as we want).
|
121
|
+
association.reload
|
122
|
+
end
|
121
123
|
end
|
122
124
|
end
|
123
125
|
|
124
126
|
def create(*args, &block)
|
125
|
-
association.create(*args, &block).tap do |
|
127
|
+
association.create(*args, &block).tap do |_|
|
126
128
|
@load_state = :ghost
|
127
129
|
load_objects
|
128
130
|
end
|
129
131
|
end
|
130
132
|
|
131
133
|
def create!(*args, &block)
|
132
|
-
association.create!(*args, &block).tap do |
|
134
|
+
association.create!(*args, &block).tap do |_|
|
133
135
|
@load_state = :ghost
|
134
136
|
load_objects
|
135
137
|
end
|
data/lib/deferring/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: deferring
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Robin Roestenburg
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-08-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|