polyamorous 0.6.3 → 0.6.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 1a960cff78a0b7755b3cb84f7d44ce6fd99f0db3
4
+ data.tar.gz: ed14c61ab54556d57ab445b50635b48466c36ba1
5
+ SHA512:
6
+ metadata.gz: 4e826b11b91c37bbedc7bc9201c90515a5a4ba02e085ff9b0827dfe2da116bba36545526a720e205a9c4a878e66ba8c384bb6942174c038cc6d15083d5777614
7
+ data.tar.gz: 2dfd89eab419e1e5301c51b30f2edff793bd721f7ce27d4a6fe4726dde9c180afcfc15a5faf703b88d80b87a6f3457c2227e4d88ea399b08f3f5da632a11945c
@@ -22,6 +22,7 @@ module Polyamorous
22
22
  if polymorphic_class && ::ActiveRecord::Base > polymorphic_class
23
23
  swapping_reflection_klass(reflection, polymorphic_class) do |reflection|
24
24
  initialize_without_polymorphism(reflection, join_dependency, parent)
25
+ self.reflection.options[:polymorphic] = true
25
26
  end
26
27
  else
27
28
  initialize_without_polymorphism(reflection, join_dependency, parent)
@@ -29,12 +30,11 @@ module Polyamorous
29
30
  end
30
31
 
31
32
  def swapping_reflection_klass(reflection, klass)
32
- reflection = reflection.clone
33
- original_polymorphic = reflection.options.delete(:polymorphic)
34
- reflection.instance_variable_set(:@klass, klass)
35
- yield reflection
36
- ensure
37
- reflection.options[:polymorphic] = original_polymorphic
33
+ new_reflection = reflection.clone
34
+ new_reflection.instance_variable_set(:@options, reflection.options.clone)
35
+ new_reflection.options.delete(:polymorphic)
36
+ new_reflection.instance_variable_set(:@klass, klass)
37
+ yield new_reflection
38
38
  end
39
39
 
40
40
  def equality_with_polymorphism(other)
@@ -1,3 +1,3 @@
1
1
  module Polyamorous
2
- VERSION = "0.6.3"
2
+ VERSION = "0.6.4"
3
3
  end
@@ -5,6 +5,7 @@ module Polyamorous
5
5
  let(:join_dependency) { new_join_dependency Note, {} }
6
6
  let(:parent) { join_dependency.join_base }
7
7
  let(:reflection) { Note.reflect_on_association(:notable) }
8
+ let(:join_association) { JoinAssociation.new(reflection, join_dependency, parent, Article) }
8
9
  subject {
9
10
  join_dependency.build_join_association_respecting_polymorphism(
10
11
  reflection, parent, Person
@@ -23,5 +24,19 @@ module Polyamorous
23
24
  )
24
25
  )
25
26
  end
27
+
28
+ it 'leaves the orginal reflection intact for thread safety' do
29
+ reflection.instance_variable_set(:@klass, Article)
30
+ join_association.swapping_reflection_klass(reflection, Person) do |new_reflection|
31
+ new_reflection.options.should_not equal reflection.options
32
+ new_reflection.options.should_not have_key(:polymorphic)
33
+ new_reflection.klass.should == Person
34
+ reflection.klass.should == Article
35
+ end
36
+ end
37
+
38
+ it 'sets the polmorphic option to true after initializing' do
39
+ join_association.options[:polymorphic].should be_true
40
+ end
26
41
  end
27
42
  end
metadata CHANGED
@@ -1,36 +1,32 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: polyamorous
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.3
5
- prerelease:
4
+ version: 0.6.4
6
5
  platform: ruby
7
6
  authors:
8
7
  - Ernie Miller
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-05-25 00:00:00.000000000 Z
11
+ date: 2013-09-05 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: activerecord
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - '>='
20
18
  - !ruby/object:Gem::Version
21
19
  version: '3.0'
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - '>='
28
25
  - !ruby/object:Gem::Version
29
26
  version: '3.0'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: rspec
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
31
  - - ~>
36
32
  - !ruby/object:Gem::Version
@@ -38,7 +34,6 @@ dependencies:
38
34
  type: :development
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
38
  - - ~>
44
39
  - !ruby/object:Gem::Version
@@ -46,7 +41,6 @@ dependencies:
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: machinist
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
45
  - - ~>
52
46
  - !ruby/object:Gem::Version
@@ -54,7 +48,6 @@ dependencies:
54
48
  type: :development
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
52
  - - ~>
60
53
  - !ruby/object:Gem::Version
@@ -62,7 +55,6 @@ dependencies:
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: faker
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
59
  - - ~>
68
60
  - !ruby/object:Gem::Version
@@ -70,7 +62,6 @@ dependencies:
70
62
  type: :development
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
66
  - - ~>
76
67
  - !ruby/object:Gem::Version
@@ -78,7 +69,6 @@ dependencies:
78
69
  - !ruby/object:Gem::Dependency
79
70
  name: sqlite3
80
71
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
72
  requirements:
83
73
  - - ~>
84
74
  - !ruby/object:Gem::Version
@@ -86,14 +76,13 @@ dependencies:
86
76
  type: :development
87
77
  prerelease: false
88
78
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
79
  requirements:
91
80
  - - ~>
92
81
  - !ruby/object:Gem::Version
93
82
  version: 1.3.3
94
- description: ! "\n This is just an extraction from Ransack/Squeel. You probably
95
- don't want to use this\n directly. It extends ActiveRecord's associations to
96
- support polymorphic belongs_to\n associations.\n "
83
+ description: "\n This is just an extraction from Ransack/Squeel. You probably don't
84
+ want to use this\n directly. It extends ActiveRecord's associations to support
85
+ polymorphic belongs_to\n associations.\n "
97
86
  email:
98
87
  - ernie@metautonomo.us
99
88
  executables: []
@@ -124,33 +113,26 @@ files:
124
113
  - spec/support/schema.rb
125
114
  homepage: http://github.com/ernie/polyamorous
126
115
  licenses: []
116
+ metadata: {}
127
117
  post_install_message:
128
118
  rdoc_options: []
129
119
  require_paths:
130
120
  - lib
131
121
  required_ruby_version: !ruby/object:Gem::Requirement
132
- none: false
133
122
  requirements:
134
- - - ! '>='
123
+ - - '>='
135
124
  - !ruby/object:Gem::Version
136
125
  version: '0'
137
- segments:
138
- - 0
139
- hash: -3873183726189601663
140
126
  required_rubygems_version: !ruby/object:Gem::Requirement
141
- none: false
142
127
  requirements:
143
- - - ! '>='
128
+ - - '>='
144
129
  - !ruby/object:Gem::Version
145
130
  version: '0'
146
- segments:
147
- - 0
148
- hash: -3873183726189601663
149
131
  requirements: []
150
132
  rubyforge_project: polyamorous
151
- rubygems_version: 1.8.25
133
+ rubygems_version: 2.0.3
152
134
  signing_key:
153
- specification_version: 3
135
+ specification_version: 4
154
136
  summary: Loves/is loved by polymorphic belongs_to associations, Ransack, Squeel, MetaSearch...
155
137
  test_files:
156
138
  - spec/blueprints/articles.rb