infopark_cloud_connector 6.8.0.beta.200.744.99f67fc → 6.8.0.beta.200.785.05d4af9
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.
- data/lib/rails_connector/obj.rb +98 -64
- data/lib/rails_connector/obj_body.rb +2 -2
- data/lib/rails_connector/obj_class.rb +7 -4
- metadata +17 -15
data/lib/rails_connector/obj.rb
CHANGED
@@ -163,7 +163,7 @@ module RailsConnector
|
|
163
163
|
end
|
164
164
|
|
165
165
|
def path_list # :nodoc:
|
166
|
-
|
166
|
+
read_attribute_value('_path') || []
|
167
167
|
end
|
168
168
|
|
169
169
|
# returns the Obj's name, i.e. the last component of the path.
|
@@ -211,7 +211,7 @@ module RailsConnector
|
|
211
211
|
|
212
212
|
# returns the obj's permalink.
|
213
213
|
def permalink
|
214
|
-
|
214
|
+
read_attribute_value('_permalink')
|
215
215
|
end
|
216
216
|
|
217
217
|
# This method determines the controller that should be invoked when the Obj is requested.
|
@@ -240,12 +240,12 @@ module RailsConnector
|
|
240
240
|
end
|
241
241
|
|
242
242
|
def title
|
243
|
-
|
243
|
+
read_attribute_value('title')
|
244
244
|
end
|
245
245
|
|
246
246
|
# Returns the type of the object: :document, :publication, :image or :generic
|
247
247
|
def object_type
|
248
|
-
|
248
|
+
read_attribute_value('_obj_type').to_sym
|
249
249
|
end
|
250
250
|
|
251
251
|
# Returns true if image? or generic?
|
@@ -364,31 +364,31 @@ module RailsConnector
|
|
364
364
|
end
|
365
365
|
|
366
366
|
def sort_order # :nodoc:
|
367
|
-
|
367
|
+
read_attribute_value('_sort_order') == 1 ? "descending" : "ascending"
|
368
368
|
end
|
369
369
|
|
370
370
|
def sort_type1 # :nodoc:
|
371
|
-
converted_sort_type(
|
371
|
+
converted_sort_type('_sort_type1')
|
372
372
|
end
|
373
373
|
|
374
374
|
def sort_type2 # :nodoc:
|
375
|
-
converted_sort_type(
|
375
|
+
converted_sort_type('_sort_type2')
|
376
376
|
end
|
377
377
|
|
378
378
|
def sort_type3 # :nodoc:
|
379
|
-
converted_sort_type(
|
379
|
+
converted_sort_type('_sort_type3')
|
380
380
|
end
|
381
381
|
|
382
382
|
def sort_key1 # :nodoc:
|
383
|
-
converted_sort_key(
|
383
|
+
converted_sort_key('_sort_key1')
|
384
384
|
end
|
385
385
|
|
386
386
|
def sort_key2 # :nodoc:
|
387
|
-
converted_sort_key(
|
387
|
+
converted_sort_key('_sort_key2')
|
388
388
|
end
|
389
389
|
|
390
390
|
def sort_key3 # :nodoc:
|
391
|
-
converted_sort_key(
|
391
|
+
converted_sort_key('_sort_key3')
|
392
392
|
end
|
393
393
|
|
394
394
|
# Returns the Object with the given name next in the hierarchy
|
@@ -399,13 +399,15 @@ module RailsConnector
|
|
399
399
|
parent.find_nearest(name) unless self.root?
|
400
400
|
end
|
401
401
|
|
402
|
-
|
402
|
+
# This should be a SET, because it's faster in this particular case.
|
403
|
+
OLD_INTERNAL_KEYS = Set.new(%w[
|
403
404
|
body
|
404
405
|
id
|
405
406
|
last_changed
|
406
407
|
name
|
407
408
|
obj_class
|
408
409
|
obj_type
|
410
|
+
object_type
|
409
411
|
path
|
410
412
|
permalink
|
411
413
|
sort_key1
|
@@ -417,20 +419,24 @@ module RailsConnector
|
|
417
419
|
sort_type3
|
418
420
|
suppress_export
|
419
421
|
text_links
|
422
|
+
title
|
420
423
|
valid_from
|
421
424
|
valid_until
|
422
|
-
)
|
423
|
-
|
424
|
-
#
|
425
|
+
])
|
426
|
+
|
427
|
+
# Returns the value of an internal or external attribute specified by its name.
|
425
428
|
# Passing an invalid key will not raise an error, but return nil.
|
426
|
-
def [](
|
427
|
-
key =
|
429
|
+
def [](key)
|
430
|
+
key = key.to_s
|
428
431
|
if OLD_INTERNAL_KEYS.include?(key)
|
429
432
|
send(key)
|
430
|
-
elsif key.start_with?('_')
|
431
|
-
|
432
|
-
|
433
|
+
elsif key.start_with?('_') && OLD_INTERNAL_KEYS.include?(internal_key = key[1..-1])
|
434
|
+
# For backwards compatibility reasons
|
435
|
+
send(internal_key)
|
436
|
+
elsif has_attribute?(key)
|
433
437
|
read_attribute(key)
|
438
|
+
else
|
439
|
+
nil
|
434
440
|
end
|
435
441
|
end
|
436
442
|
|
@@ -443,23 +449,23 @@ module RailsConnector
|
|
443
449
|
end
|
444
450
|
|
445
451
|
def text_links
|
446
|
-
|
452
|
+
read_attribute_value('_text_links')
|
447
453
|
end
|
448
454
|
|
449
455
|
def obj_class
|
450
|
-
|
456
|
+
read_attribute_value('_obj_class')
|
451
457
|
end
|
452
458
|
|
453
459
|
def last_changed
|
454
|
-
|
460
|
+
read_attribute_value('_last_changed')
|
455
461
|
end
|
456
462
|
|
457
463
|
def valid_from
|
458
|
-
|
464
|
+
read_attribute_value('_valid_from')
|
459
465
|
end
|
460
466
|
|
461
467
|
def valid_until
|
462
|
-
|
468
|
+
read_attribute_value('_valid_until')
|
463
469
|
end
|
464
470
|
|
465
471
|
# For a binary Obj, the content_type is equal to the content_type of it's body (i.e. it's data).
|
@@ -497,12 +503,7 @@ module RailsConnector
|
|
497
503
|
# Returns a list of the names of all custom attributes defined for this Obj as Symbols.
|
498
504
|
# A custom attribute is a user-defined attribute, i.e. one that is not built-in in the CMS.
|
499
505
|
def custom_attribute_names
|
500
|
-
attributes.
|
501
|
-
end
|
502
|
-
|
503
|
-
def has_attribute?(name)
|
504
|
-
name_as_string = name.to_s
|
505
|
-
@values.has_key?(name_as_string) || attributes.has_key?(name_as_string)
|
506
|
+
obj_class_instance.attributes.map(&:to_sym)
|
506
507
|
end
|
507
508
|
|
508
509
|
def self.preview_time=(t) # :nodoc:
|
@@ -517,52 +518,85 @@ module RailsConnector
|
|
517
518
|
"<#{self.class} id=\"#{id}\" path=\"#{path}\">"
|
518
519
|
end
|
519
520
|
|
521
|
+
def has_attribute?(name)
|
522
|
+
obj_class_instance.has_attribute?(name)
|
523
|
+
end
|
524
|
+
|
520
525
|
private
|
521
526
|
|
527
|
+
def obj_class_instance
|
528
|
+
ObjClass.by_name(obj_class)
|
529
|
+
end
|
530
|
+
|
522
531
|
def update_data(values = {}, meta = {})
|
523
532
|
@values = values || {}
|
524
533
|
meta ||= {}
|
525
|
-
@rtc_ref = meta[
|
526
|
-
@ext_ref = meta[
|
527
|
-
@
|
534
|
+
@rtc_ref = meta['rtc_ref']
|
535
|
+
@ext_ref = meta['ext_ref']
|
536
|
+
@attribute_cache = {}
|
528
537
|
end
|
529
538
|
|
530
|
-
def
|
531
|
-
|
532
|
-
|
533
|
-
|
534
|
-
|
535
|
-
|
536
|
-
|
537
|
-
end
|
538
|
-
else
|
539
|
-
{}
|
540
|
-
end
|
541
|
-
) : {}
|
539
|
+
def read_attribute(attribute_name)
|
540
|
+
attribute_type = Attribute.type_of(attribute_name)
|
541
|
+
if type_of(attribute_name) == attribute_type
|
542
|
+
read_attribute_value(attribute_name, attribute_type)
|
543
|
+
else
|
544
|
+
default_attribute_value(attribute_type)
|
545
|
+
end
|
542
546
|
end
|
543
547
|
|
544
|
-
def
|
545
|
-
|
546
|
-
|
548
|
+
def read_attribute_value(attribute_name, attribute_type = nil)
|
549
|
+
@attribute_cache.fetch(attribute_name) do
|
550
|
+
attribute_type ||= type_of(attribute_name)
|
551
|
+
attribute_value = read_raw_attribute_value(attribute_name)
|
552
|
+
@attribute_cache[attribute_name] =
|
553
|
+
prepare_attribute_value(attribute_name, attribute_type, attribute_value)
|
554
|
+
end
|
547
555
|
end
|
548
556
|
|
549
|
-
def
|
550
|
-
|
551
|
-
case type_of(name)
|
557
|
+
def prepare_attribute_value(attribute_name, attribute_type, attribute_value)
|
558
|
+
case attribute_type
|
552
559
|
when :markdown
|
553
|
-
StringTagging.tag_as_markdown(
|
560
|
+
StringTagging.tag_as_markdown(attribute_value, self)
|
554
561
|
when :html
|
555
|
-
StringTagging.tag_as_html(
|
562
|
+
StringTagging.tag_as_html(attribute_value, self)
|
556
563
|
when :date
|
557
|
-
DateAttribute.parse
|
564
|
+
DateAttribute.parse(attribute_value) if attribute_value
|
558
565
|
when :linklist
|
559
|
-
if
|
560
|
-
LinkList.new(
|
566
|
+
if attribute_name == '_text_links'
|
567
|
+
LinkList.new(attribute_value && attribute_value.values)
|
561
568
|
else
|
562
|
-
LinkList.new(
|
569
|
+
LinkList.new(attribute_value)
|
570
|
+
end
|
571
|
+
else
|
572
|
+
attribute_value
|
573
|
+
end
|
574
|
+
end
|
575
|
+
|
576
|
+
def default_attribute_value(attribute_type)
|
577
|
+
case attribute_type
|
578
|
+
when :linklist
|
579
|
+
LinkList.new(nil)
|
580
|
+
when :multienum
|
581
|
+
[]
|
582
|
+
else
|
583
|
+
nil
|
584
|
+
end
|
585
|
+
end
|
586
|
+
|
587
|
+
def attributes
|
588
|
+
@attributes ||= @rtc_ref ? attributes_from_rtc : {}
|
589
|
+
end
|
590
|
+
|
591
|
+
def attributes_from_rtc
|
592
|
+
rtc = DictStorage.get(@rtc_ref)
|
593
|
+
if rtc['obj_classes'] && rtc['attributes'] && oc = rtc['obj_classes'][@values['_obj_class']]
|
594
|
+
rtc['attributes'].inject({}) do |attrs, (name, value)|
|
595
|
+
attrs[name] = value if oc['attributes'] && oc['attributes'].include?(name)
|
596
|
+
attrs
|
563
597
|
end
|
564
598
|
else
|
565
|
-
|
599
|
+
{}
|
566
600
|
end
|
567
601
|
end
|
568
602
|
|
@@ -591,9 +625,9 @@ module RailsConnector
|
|
591
625
|
DateAttribute.parse(value) unless value.nil?
|
592
626
|
end
|
593
627
|
|
594
|
-
def method_missing(
|
595
|
-
if has_attribute?(
|
596
|
-
read_attribute(
|
628
|
+
def method_missing(method_name, *args) # :nodoc:
|
629
|
+
if has_attribute?(method_name)
|
630
|
+
read_attribute(method_name.to_s)
|
597
631
|
else
|
598
632
|
super
|
599
633
|
end
|
@@ -620,11 +654,11 @@ module RailsConnector
|
|
620
654
|
end
|
621
655
|
|
622
656
|
def converted_sort_type(attribute)
|
623
|
-
|
657
|
+
read_attribute_value(attribute) == 1 ? "numeric" : "alphaNumeric"
|
624
658
|
end
|
625
659
|
|
626
660
|
def converted_sort_key(attribute)
|
627
|
-
key =
|
661
|
+
key = read_attribute_value(attribute)
|
628
662
|
case key
|
629
663
|
when "_valid_until"
|
630
664
|
"_valid_until"
|
@@ -7,7 +7,7 @@ module ObjBody
|
|
7
7
|
if binary?
|
8
8
|
nil
|
9
9
|
else
|
10
|
-
StringTagging.tag_as_html(
|
10
|
+
StringTagging.tag_as_html(read_attribute_value('body'), self)
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
@@ -52,7 +52,7 @@ module ObjBody
|
|
52
52
|
private
|
53
53
|
|
54
54
|
def find_blob
|
55
|
-
blob_spec =
|
55
|
+
blob_spec = read_attribute_value('blob')
|
56
56
|
Blob.find(blob_spec["id"], :context => path) if blob_spec
|
57
57
|
end
|
58
58
|
end
|
@@ -1,15 +1,18 @@
|
|
1
1
|
#:enddoc:
|
2
2
|
module RailsConnector
|
3
3
|
class ObjClass
|
4
|
-
attr_reader :name
|
4
|
+
attr_reader :name, :attributes
|
5
5
|
|
6
6
|
def initialize(data)
|
7
|
-
@name, @attributes = data['name'], data['attributes']
|
7
|
+
@name, @attributes = data['name'], data['attributes'] || []
|
8
8
|
end
|
9
9
|
|
10
10
|
def self.by_name(name)
|
11
|
-
data = Revision.current.obj_classes[name.to_s]
|
12
|
-
|
11
|
+
if data = Revision.current.obj_classes[name.to_s]
|
12
|
+
new(data)
|
13
|
+
else
|
14
|
+
raise ResourceNotFound, "Could not find #{self} with name #{name}"
|
15
|
+
end
|
13
16
|
end
|
14
17
|
|
15
18
|
def has_attribute?(attribute_name)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: infopark_cloud_connector
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 77657614921
|
5
5
|
prerelease: 6
|
6
6
|
segments:
|
7
7
|
- 6
|
@@ -9,12 +9,13 @@ version: !ruby/object:Gem::Version
|
|
9
9
|
- 0
|
10
10
|
- beta
|
11
11
|
- 200
|
12
|
-
-
|
13
|
-
-
|
14
|
-
-
|
15
|
-
-
|
16
|
-
-
|
17
|
-
|
12
|
+
- 785
|
13
|
+
- 5
|
14
|
+
- d
|
15
|
+
- 4
|
16
|
+
- af
|
17
|
+
- 9
|
18
|
+
version: 6.8.0.beta.200.785.05d4af9
|
18
19
|
platform: ruby
|
19
20
|
authors:
|
20
21
|
- Infopark AG
|
@@ -22,7 +23,7 @@ autorequire:
|
|
22
23
|
bindir: bin
|
23
24
|
cert_chain: []
|
24
25
|
|
25
|
-
date: 2012-07-
|
26
|
+
date: 2012-07-18 00:00:00 +02:00
|
26
27
|
default_executable:
|
27
28
|
dependencies:
|
28
29
|
- !ruby/object:Gem::Dependency
|
@@ -63,19 +64,20 @@ dependencies:
|
|
63
64
|
requirements:
|
64
65
|
- - "="
|
65
66
|
- !ruby/object:Gem::Version
|
66
|
-
hash:
|
67
|
+
hash: 77657614921
|
67
68
|
segments:
|
68
69
|
- 6
|
69
70
|
- 8
|
70
71
|
- 0
|
71
72
|
- beta
|
72
73
|
- 200
|
73
|
-
-
|
74
|
-
-
|
75
|
-
-
|
76
|
-
-
|
77
|
-
-
|
78
|
-
|
74
|
+
- 785
|
75
|
+
- 5
|
76
|
+
- d
|
77
|
+
- 4
|
78
|
+
- af
|
79
|
+
- 9
|
80
|
+
version: 6.8.0.beta.200.785.05d4af9
|
79
81
|
version_requirements: *id003
|
80
82
|
name: kvom
|
81
83
|
prerelease: false
|