active_remote 2.3.5 → 2.4.0

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: 871244345230901e224ca7000aa07364f7a7ae0d
4
- data.tar.gz: 9278a6bd39c5716cc91c07e9215483e861a2fd00
3
+ metadata.gz: 7f95e9d97b5f04b0f9cfb65f1fa67b1c28610494
4
+ data.tar.gz: 20ab489954edb8912d271122b5c153a84029328e
5
5
  SHA512:
6
- metadata.gz: 49fb3485f8d4d41096127ea8545e21f2ec3e96af66eae16a814640fb51adcdf4848c7d2239a340f9a48cafb0edcad83187a24035242dc1b7647220c02e952e89
7
- data.tar.gz: 63ed79b6d31fdf88473869d965d6d76c56c924c1352ab552eb90489a09d10d991bb40a9f4b37b885a2caf8f1d25f29ce366256d42603465e4192961b2093183f
6
+ metadata.gz: 0766023e587197504ce97037fbcb771354ed3b99144707765bb5d924ebc35e96701f008a90278938b91457da216e1da49e13f7d71b76ae51af818e56820d10de
7
+ data.tar.gz: 929d191533ec354c95449201ef31f9f5043c603d18e6316c83b09196ef3203f8552597afd8aef354793fdfd25871ddecb63718e475b4da810379e3e3166a09d4
@@ -132,6 +132,17 @@ module ActiveRemote
132
132
 
133
133
  private
134
134
 
135
+ def create_setter_method(associated_klass, options={})
136
+ writer_method = "#{associated_klass}=".to_sym
137
+ define_method(writer_method) do |new_value|
138
+ klass_name = options.fetch(:class_name){ associated_klass }
139
+ klass = klass_name.to_s.classify.constantize
140
+
141
+ instance_variable_set(:"@#{new_value.class.name.demodulize.underscore}", new_value)
142
+ new_value
143
+ end
144
+ end
145
+
135
146
  def perform_association(associated_klass, options={})
136
147
  define_method(associated_klass) do
137
148
  klass_name = options.fetch(:class_name){ associated_klass }
@@ -148,6 +159,8 @@ module ActiveRemote
148
159
 
149
160
  return value
150
161
  end
162
+
163
+ create_setter_method(associated_klass, options)
151
164
  end
152
165
  end
153
166
  end
@@ -1,3 +1,3 @@
1
1
  module ActiveRemote
2
- VERSION = "2.3.5"
2
+ VERSION = "2.4.0"
3
3
  end
@@ -12,6 +12,7 @@ describe ActiveRemote::Association do
12
12
  subject { Post.new(:author_guid => author_guid, :user_guid => user_guid) }
13
13
 
14
14
  it { is_expected.to respond_to(:author) }
15
+ it { is_expected.to respond_to(:author=) }
15
16
 
16
17
  it "searches the associated model for a single record" do
17
18
  expect(Author).to receive(:search).with(:guid => subject.author_guid).and_return(records)
@@ -62,7 +63,6 @@ describe ActiveRemote::Association do
62
63
  end
63
64
  end
64
65
  end
65
-
66
66
  end
67
67
 
68
68
  context "specific association with class name" do
@@ -75,6 +75,10 @@ describe ActiveRemote::Association do
75
75
  expect(Author).to receive(:search).with(:guid => subject.author_guid).and_return(records)
76
76
  expect(subject.coauthor).to eq record
77
77
  end
78
+
79
+ it "should create a setter method" do
80
+ expect(subject).to respond_to(:coauthor=)
81
+ end
78
82
  end
79
83
 
80
84
  context "specific association with class name and foreign_key" do
@@ -181,6 +185,7 @@ describe ActiveRemote::Association do
181
185
  subject { Category.new(category_attributes) }
182
186
 
183
187
  it { is_expected.to respond_to(:author) }
188
+ it { is_expected.to respond_to(:author=) }
184
189
 
185
190
  it "searches the associated model for all associated records" do
186
191
  expect(Author).to receive(:search).with(:category_guid => subject.guid).and_return(records)
@@ -214,6 +219,10 @@ describe ActiveRemote::Association do
214
219
  expect(Author).to receive(:search).with(:category_guid => subject.guid).and_return(records)
215
220
  expect(subject.senior_author).to eq record
216
221
  end
222
+
223
+ it "should create a setter method" do
224
+ expect(subject).to respond_to(:senior_author=)
225
+ end
217
226
  end
218
227
 
219
228
  context "specific association with class name and foreign_key" do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_remote
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.5
4
+ version: 2.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Hutchison
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-01-13 00:00:00.000000000 Z
11
+ date: 2017-02-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: active_attr
@@ -265,7 +265,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
265
265
  version: '0'
266
266
  requirements: []
267
267
  rubyforge_project:
268
- rubygems_version: 2.6.8
268
+ rubygems_version: 2.6.10
269
269
  signing_key:
270
270
  specification_version: 4
271
271
  summary: Active Record for your platform