deferred_associations 0.5.6 → 0.5.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- YTc4NmE0YTU4OWY2NDIzOTRkOGE4OTk1YjU4OGNkZWM4Y2EzNTc0Mg==
5
- data.tar.gz: !binary |-
6
- N2MwNTZhOTE3MWM2MTQzYmIyZWRmMDRkMjM0OTFmMjFjOGJlZmRiMQ==
2
+ SHA1:
3
+ metadata.gz: 80ea93f4951198652fc52f31762e2bbfba01b748
4
+ data.tar.gz: 5ac0e402760f95e2cdca7eda2b2f7be32c20e295
7
5
  SHA512:
8
- metadata.gz: !binary |-
9
- MGI0MjliNWFmNWVkN2E0MjJhZTUzNjRjNjdkNGYzOTY4NGMwNGYyYjdjYmUx
10
- ZTAzY2Q1MDlhODZhMGJhOGExYTE3ODNmOGIwMGE5ZGM0ZGU2NjE1MmNhZDhh
11
- ODJmYzE0NjkzMjNmNGU3NTFjNmU0ZmI4YzFlMWEwZWZiMTFhNjE=
12
- data.tar.gz: !binary |-
13
- YjUyZGExNGUwN2NjYTgwNmM4NjE3NjViZmMyMGVlYjA2ODFmNjM1MjUzNzM3
14
- ZjY4YWI4YjJmY2I3MmY3OWUxN2U1NmQxMWI0MGUzZDRmYjMwNTViMmRlYzBl
15
- ZGE5OTA3YWVlYWYyNjk2OGNhMzMzZTU2YWNhZTFmNzNkZDM5NzE=
6
+ metadata.gz: ffb66400841e0f0b3ff3c94578c819d6f3048b9992399af672dba43aa46ee9aa80f645dfb543702f471c0de24cbeb677eb5b93e714e9e1f9e641270d276bc4b5
7
+ data.tar.gz: be23972de665dfbcbe5be755a439ad98816caaf787db53c794311e03da12d7966f198d1b7ca0e8c1f7de5ce3446cccf677b835b9aee42505c10b42eb8dda92f1
data/CHANGELOG CHANGED
@@ -1,3 +1,7 @@
1
+ 0.5.7
2
+ =====
3
+ * fix a problem, when model is loaded multiple times
4
+
1
5
  0.5.6
2
6
  =====
3
7
  * .reload method on AR objects can contain an optional parameter. Our alias method
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "deferred_associations"
8
- s.version = "0.5.6"
8
+ s.version = "0.5.7"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Martin Koerner", "Tyler Rick", "Alessio Caiazza"]
@@ -16,10 +16,13 @@ module ActiveRecord
16
16
  # end
17
17
  # end
18
18
  def has_and_belongs_to_many_with_deferred_save(*args)
19
- has_and_belongs_to_many *args
20
19
  collection_name = args[0].to_s
21
20
  collection_singular_ids = collection_name.singularize + "_ids"
22
21
 
22
+ return if method_defined?("#{collection_name}_with_deferred_save")
23
+
24
+ has_and_belongs_to_many *args
25
+
23
26
  add_deletion_callback
24
27
 
25
28
  attr_accessor :"unsaved_#{collection_name}"
@@ -3,9 +3,11 @@ module ActiveRecord
3
3
  module ClassMethods
4
4
 
5
5
  def has_many_with_deferred_save *args
6
- has_many *args
6
+ collection_name = args[0].to_s
7
+
8
+ return if method_defined?("#{collection_name}_with_deferred_save")
7
9
 
8
- collection_name = args[0].to_s
10
+ has_many *args
9
11
 
10
12
  if args[1].is_a?(Hash) && args[1].keys.include?(:through)
11
13
  logger.warn "You are using the option :through on #{self.name}##{collection_name}. This was not tested very much with has_many_with_deferred_save. Please write many tests for your functionality!"
@@ -68,7 +68,7 @@ describe "has_and_belongs_to_many_with_deferred_save" do
68
68
  @room.reload
69
69
  @room.people.size. should == 2
70
70
  @room.people_without_deferred_save.size. should == 2
71
- @people.map {|p| p.reload; p.rooms.size}. should == [1, 1, 0]
71
+ @people.map {|p| p.reload; p.rooms.size}. should == [1, 1, 0]
72
72
  end
73
73
 
74
74
  it "if they try to go around our accessors and use the original accessors, then (and only then) will the exception be raised in before_adding_person..." do
data/spec/models/room.rb CHANGED
@@ -13,6 +13,9 @@ class Room < ActiveRecord::Base
13
13
  has_many_with_deferred_save :tables
14
14
  has_many_with_deferred_save :chairs, :through => :tables #TODO test compatibility with through associations
15
15
 
16
+ has_and_belongs_to_many_with_deferred_save :doors
17
+ has_many_with_deferred_save :tables
18
+
16
19
  before_save :diff_after_module
17
20
 
18
21
  validate :people_count
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: deferred_associations
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.6
4
+ version: 0.5.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Martin Koerner
@@ -16,35 +16,34 @@ dependencies:
16
16
  name: activerecord
17
17
  requirement: !ruby/object:Gem::Requirement
18
18
  requirements:
19
- - - ! '>='
19
+ - - ">="
20
20
  - !ruby/object:Gem::Version
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
25
25
  requirements:
26
- - - ! '>='
26
+ - - ">="
27
27
  - !ruby/object:Gem::Version
28
28
  version: '0'
29
29
  - !ruby/object:Gem::Dependency
30
30
  name: rspec
31
31
  requirement: !ruby/object:Gem::Requirement
32
32
  requirements:
33
- - - ! '>='
33
+ - - ">="
34
34
  - !ruby/object:Gem::Version
35
35
  version: '0'
36
36
  type: :development
37
37
  prerelease: false
38
38
  version_requirements: !ruby/object:Gem::Requirement
39
39
  requirements:
40
- - - ! '>='
40
+ - - ">="
41
41
  - !ruby/object:Gem::Version
42
42
  version: '0'
43
- description: ! "Makes ActiveRecord defer/postpone saving the records you add to an
44
- habtm (has_and_belongs_to_many) or has_many\n association
45
- until you call model.save, allowing validation in the style of normal attributes.
46
- Additionally you\n can check inside before_save filters, if
47
- the association was altered."
43
+ description: |-
44
+ Makes ActiveRecord defer/postpone saving the records you add to an habtm (has_and_belongs_to_many) or has_many
45
+ association until you call model.save, allowing validation in the style of normal attributes. Additionally you
46
+ can check inside before_save filters, if the association was altered.
48
47
  email: martin.koerner@objectfab.de
49
48
  executables: []
50
49
  extensions: []
@@ -81,12 +80,12 @@ require_paths:
81
80
  - lib
82
81
  required_ruby_version: !ruby/object:Gem::Requirement
83
82
  requirements:
84
- - - ! '>='
83
+ - - ">="
85
84
  - !ruby/object:Gem::Version
86
85
  version: '0'
87
86
  required_rubygems_version: !ruby/object:Gem::Requirement
88
87
  requirements:
89
- - - ! '>='
88
+ - - ">="
90
89
  - !ruby/object:Gem::Version
91
90
  version: '0'
92
91
  requirements: []