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: 533c02589a0e9c2ae8d48d47d3746ae7234633e7
4
- data.tar.gz: cd023ba8e4b6f3cb9075a667503b26c1c8a60354
3
+ metadata.gz: d3b21ec82ca5a7c3f62259abc852c195553ebed1
4
+ data.tar.gz: b2a2819985c21278781a1ef8fd1d6b97fef61945
5
5
  SHA512:
6
- metadata.gz: 90d31875102fdd4120714e484f7e30770f2324663fabc5dde2925787c63264fc41812458d4f0605c3b9b1e413654ab8613f52e5aaf01255024564c4c5e7083df
7
- data.tar.gz: 2f4042d509e4b1f497e6b04db21bbf35fee8cddb28254e7ee24e7bf9425adf0be142c6dbeceed1c47a7eaf8a0a2ce8ad424635993d2e61f82c0d7040c34bf355
6
+ metadata.gz: 8181bd48cfbef4cc775fcb9a58a24ae60ead0555377fe87551e0629078453d4d55b03e8e7f04cafe3820c4839bfd22cca24dc6cee6921c1e121d5598971aaf81
7
+ data.tar.gz: 0b2c33f182e9ce5e2d1b66ecf42cb16abc2f4b92f1bcc5afbbb173f2b8dd919c71876cc66305d3f3d280340351e18993af686c6f5b846f5d3128ac1a1a0d9432
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ../
3
3
  specs:
4
- deferring (0.0.2)
4
+ deferring (0.0.4)
5
5
  activerecord (> 3.0)
6
6
 
7
7
  GEM
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ../
3
3
  specs:
4
- deferring (0.0.2)
4
+ deferring (0.0.4)
5
5
  activerecord (> 3.0)
6
6
 
7
7
  GEM
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ../
3
3
  specs:
4
- deferring (0.0.2)
4
+ deferring (0.0.4)
5
5
  activerecord (> 3.0)
6
6
 
7
7
  GEM
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ../
3
3
  specs:
4
- deferring (0.0.2)
4
+ deferring (0.0.4)
5
5
  activerecord (> 3.0)
6
6
 
7
7
  GEM
@@ -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 |result|
115
- objects.push(result)
114
+ association.build(*args, &block).tap do |record|
115
+ run_deferring_callbacks(:link, record) do
116
+ objects.push(record)
116
117
 
117
- # Remove the newly build record from the original association. If we
118
- # didn't do this, the new record would be saved to the database when
119
- # saving the parent object (and not after, as we want).
120
- association.reload
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 |result|
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 |result|
134
+ association.create!(*args, &block).tap do |_|
133
135
  @load_state = :ghost
134
136
  load_objects
135
137
  end
@@ -1,5 +1,5 @@
1
1
  # encoding: UTF-8
2
2
 
3
3
  module Deferring
4
- VERSION = '0.0.3'
4
+ VERSION = '0.0.4'
5
5
  end
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.3
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-07-24 00:00:00.000000000 Z
11
+ date: 2014-08-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord