infopark_reactor 1.20.2 → 1.20.3

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: 70ab88a38947b88c87f42fa56578bca63d39d5cc
4
- data.tar.gz: f47aa9aa911c0a619fa5fdff8e015864050a38e8
3
+ metadata.gz: b0d4cdc9b5a3e3e40cff91833be18dbed74bfbd6
4
+ data.tar.gz: 9f58e6890f99908e7690e5aa1b668c0bf915e384
5
5
  SHA512:
6
- metadata.gz: 42273a654a39f33f0ea848cff6d3ddc97186d3d3b59b89c6d11f465376b22f9ca41700a2750f7175283e6e33e734db50bdf25a43920358acf4b998649597f311
7
- data.tar.gz: 0b319684ebcf5a4308cb73810df3def0941ae1321313aa14669497938e13a0fb89e27f7f6e490463fd95a8326e6881a8c97b582f0ceb6bb654749485d067c2d2
6
+ metadata.gz: 8ec0832951ca68a4474fc8f1ee8bbb7b00bf2d70bc9e2fe0a9252982a265c302fc26dc5656e57c7bf647e29fc909f6b8178e36a7eee5d6567cc3d22b520b8815
7
+ data.tar.gz: 48d62d3954be30727d2e8caca055888a468feeb1850ac8f19dc7c765cbce28d4b72a5935856eaeabf93afdc7059cae06120ebd1102129f7688623000d8ebc1ad
@@ -0,0 +1,17 @@
1
+ module Reactor
2
+ module Attributes
3
+ class LinkListFromAccessor
4
+ def initialize(obj, attribute)
5
+ self.obj = obj
6
+ self.attribute = attribute
7
+ end
8
+
9
+ def call
10
+ self.obj[self.attribute.to_sym] || RailsConnector::LinkList.new([])
11
+ end
12
+
13
+ protected
14
+ attr_accessor :obj, :attribute
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,19 @@
1
+ module Reactor
2
+ module Attributes
3
+ class LinkListFromAttrValues
4
+ def initialize(obj, attribute)
5
+ self.obj = obj
6
+ self.attribute = attribute
7
+ end
8
+
9
+ def call
10
+ (self.obj.attr_values[self.attribute.to_s] || []).map do |link_data|
11
+ RailsConnector::Link.new(link_data)
12
+ end
13
+ end
14
+
15
+ protected
16
+ attr_accessor :obj, :attribute
17
+ end
18
+ end
19
+ end
@@ -1,4 +1,7 @@
1
1
  # -*- encoding : utf-8 -*-
2
+ require 'reactor/attributes/link_list_from_accessor'
3
+ require 'reactor/attributes/link_list_from_attr_values'
4
+
2
5
  module Reactor
3
6
  module Persistence
4
7
  # Provides API for writing into the Content Manager.
@@ -249,25 +252,6 @@ module Reactor
249
252
  raise RuntimeError, "Unsupported Rails version!"
250
253
  end
251
254
 
252
-
253
- =begin
254
- # @see [ActiveRecord::Persistence#update_attributes]
255
- def update_attributes(attributes, options={})
256
- attributes.each do |attr, value|
257
- self.send(:"#{attr}=", value)
258
- end
259
- self.save
260
- end
261
-
262
- # @see [ActiveRecord::Persistence#update_attributes!]
263
- def update_attributes!(attributes, options={})
264
- attributes.each do |attr, value|
265
- self.send(:"#{attr}=", value)
266
- end
267
- self.save!
268
- end
269
- =end
270
-
271
255
  # Equivalent to Obj#edited?
272
256
  def really_edited?
273
257
  self.edited?
@@ -335,7 +319,7 @@ module Reactor
335
319
 
336
320
  new_links = {}.tap do |result|
337
321
  linklists.map do |field|
338
- result[field] = self.__read_link(field).map do |l|
322
+ result[field] = Reactor::Attributes::LinkListFromAccessor.new(self, field).call.map do |l|
339
323
  {:link_id => l.id, :title => l.title, :destination_url => (l.internal? ? l.destination_object.path : l.url), :target => l.target}
340
324
  end
341
325
  end
@@ -352,7 +336,7 @@ module Reactor
352
336
  copy = RailsConnector::AbstractObj.uncached { RailsConnector::AbstractObj.find(self.id) }
353
337
 
354
338
  linklists.each do |linklist|
355
- original_link_ids = copy.__read_link(linklist).original_link_ids
339
+ original_link_ids = Reactor::Attributes::LinkListFromAttrValues.new(copy, linklist).call.map(&:id)
356
340
  i = 0
357
341
  common = [original_link_ids.length,
358
342
  new_links[linklist].length].min
@@ -385,10 +369,6 @@ module Reactor
385
369
  self.class.connection.clear_query_cache
386
370
  end
387
371
 
388
- def __read_link(name)
389
- self[name.to_sym] || RailsConnector::LinkList.new([])
390
- end
391
-
392
372
  private
393
373
 
394
374
  # TODO: test it & make it public
@@ -1,4 +1,4 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
  module Reactor
3
- VERSION = "1.20.2"
3
+ VERSION = "1.20.3"
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: infopark_reactor
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.20.2
4
+ version: 1.20.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tomasz Przedmojski
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-01 00:00:00.000000000 Z
11
+ date: 2016-05-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -120,6 +120,8 @@ files:
120
120
  - lib/reactor/attributes/date_serializer.rb
121
121
  - lib/reactor/attributes/html_serializer.rb
122
122
  - lib/reactor/attributes/link_list_extender.rb
123
+ - lib/reactor/attributes/link_list_from_accessor.rb
124
+ - lib/reactor/attributes/link_list_from_attr_values.rb
123
125
  - lib/reactor/attributes/link_list_serializer.rb
124
126
  - lib/reactor/cache/permission.rb
125
127
  - lib/reactor/cache/user.rb
@@ -230,7 +232,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
230
232
  version: '0'
231
233
  requirements: []
232
234
  rubyforge_project:
233
- rubygems_version: 2.0.14
235
+ rubygems_version: 2.0.14.1
234
236
  signing_key:
235
237
  specification_version: 4
236
238
  summary: Write into CM in familiar, Rails-like way