origami-docspring 2.2.0 → 2.3.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.
Files changed (118) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +18 -0
  3. data/examples/attachments/attachment.rb +7 -8
  4. data/examples/attachments/nested_document.rb +6 -5
  5. data/examples/encryption/encryption.rb +5 -4
  6. data/examples/events/events.rb +7 -6
  7. data/examples/flash/flash.rb +10 -9
  8. data/examples/forms/javascript.rb +14 -13
  9. data/examples/forms/xfa.rb +67 -66
  10. data/examples/javascript/hello_world.rb +6 -5
  11. data/examples/javascript/js_emulation.rb +26 -26
  12. data/examples/loop/goto.rb +12 -11
  13. data/examples/loop/named.rb +17 -16
  14. data/examples/signature/signature.rb +11 -11
  15. data/examples/uri/javascript.rb +25 -24
  16. data/examples/uri/open-uri.rb +5 -4
  17. data/examples/uri/submitform.rb +11 -10
  18. data/lib/origami/3d.rb +330 -334
  19. data/lib/origami/acroform.rb +267 -268
  20. data/lib/origami/actions.rb +266 -278
  21. data/lib/origami/annotations.rb +659 -670
  22. data/lib/origami/array.rb +192 -196
  23. data/lib/origami/boolean.rb +66 -70
  24. data/lib/origami/catalog.rb +360 -363
  25. data/lib/origami/collections.rb +132 -133
  26. data/lib/origami/compound.rb +125 -129
  27. data/lib/origami/destinations.rb +226 -237
  28. data/lib/origami/dictionary.rb +155 -154
  29. data/lib/origami/encryption.rb +967 -923
  30. data/lib/origami/extensions/fdf.rb +270 -275
  31. data/lib/origami/extensions/ppklite.rb +323 -328
  32. data/lib/origami/filespec.rb +170 -173
  33. data/lib/origami/filters/ascii.rb +162 -167
  34. data/lib/origami/filters/ccitt/tables.rb +248 -252
  35. data/lib/origami/filters/ccitt.rb +309 -312
  36. data/lib/origami/filters/crypt.rb +31 -34
  37. data/lib/origami/filters/dct.rb +47 -50
  38. data/lib/origami/filters/flate.rb +57 -60
  39. data/lib/origami/filters/jbig2.rb +50 -53
  40. data/lib/origami/filters/jpx.rb +40 -43
  41. data/lib/origami/filters/lzw.rb +151 -155
  42. data/lib/origami/filters/predictors.rb +250 -255
  43. data/lib/origami/filters/runlength.rb +111 -115
  44. data/lib/origami/filters.rb +319 -325
  45. data/lib/origami/font.rb +173 -177
  46. data/lib/origami/functions.rb +62 -66
  47. data/lib/origami/graphics/colors.rb +203 -208
  48. data/lib/origami/graphics/instruction.rb +79 -81
  49. data/lib/origami/graphics/path.rb +141 -144
  50. data/lib/origami/graphics/patterns.rb +156 -160
  51. data/lib/origami/graphics/render.rb +51 -47
  52. data/lib/origami/graphics/state.rb +144 -142
  53. data/lib/origami/graphics/text.rb +185 -188
  54. data/lib/origami/graphics/xobject.rb +818 -804
  55. data/lib/origami/graphics.rb +25 -26
  56. data/lib/origami/header.rb +63 -65
  57. data/lib/origami/javascript.rb +718 -651
  58. data/lib/origami/linearization.rb +284 -285
  59. data/lib/origami/metadata.rb +156 -135
  60. data/lib/origami/name.rb +98 -100
  61. data/lib/origami/null.rb +49 -51
  62. data/lib/origami/numeric.rb +133 -135
  63. data/lib/origami/obfuscation.rb +180 -182
  64. data/lib/origami/object.rb +634 -631
  65. data/lib/origami/optionalcontent.rb +147 -149
  66. data/lib/origami/outline.rb +46 -48
  67. data/lib/origami/outputintents.rb +76 -77
  68. data/lib/origami/page.rb +637 -596
  69. data/lib/origami/parser.rb +214 -221
  70. data/lib/origami/parsers/fdf.rb +44 -45
  71. data/lib/origami/parsers/pdf/lazy.rb +147 -154
  72. data/lib/origami/parsers/pdf/linear.rb +104 -109
  73. data/lib/origami/parsers/pdf.rb +109 -107
  74. data/lib/origami/parsers/ppklite.rb +44 -46
  75. data/lib/origami/pdf.rb +886 -896
  76. data/lib/origami/reference.rb +116 -120
  77. data/lib/origami/signature.rb +617 -625
  78. data/lib/origami/stream.rb +560 -558
  79. data/lib/origami/string.rb +366 -368
  80. data/lib/origami/template/patterns.rb +50 -52
  81. data/lib/origami/template/widgets.rb +111 -114
  82. data/lib/origami/trailer.rb +153 -157
  83. data/lib/origami/tree.rb +55 -57
  84. data/lib/origami/version.rb +19 -19
  85. data/lib/origami/webcapture.rb +87 -90
  86. data/lib/origami/xfa/config.rb +409 -414
  87. data/lib/origami/xfa/connectionset.rb +113 -117
  88. data/lib/origami/xfa/datasets.rb +38 -42
  89. data/lib/origami/xfa/localeset.rb +33 -37
  90. data/lib/origami/xfa/package.rb +49 -52
  91. data/lib/origami/xfa/pdf.rb +54 -59
  92. data/lib/origami/xfa/signature.rb +33 -37
  93. data/lib/origami/xfa/sourceset.rb +34 -38
  94. data/lib/origami/xfa/stylesheet.rb +35 -39
  95. data/lib/origami/xfa/template.rb +1630 -1634
  96. data/lib/origami/xfa/xdc.rb +33 -37
  97. data/lib/origami/xfa/xfa.rb +132 -123
  98. data/lib/origami/xfa/xfdf.rb +34 -38
  99. data/lib/origami/xfa/xmpmeta.rb +34 -38
  100. data/lib/origami/xfa.rb +50 -53
  101. data/lib/origami/xreftable.rb +462 -462
  102. data/lib/origami.rb +37 -38
  103. data/test/test_actions.rb +22 -20
  104. data/test/test_annotations.rb +54 -52
  105. data/test/test_forms.rb +23 -21
  106. data/test/test_native_types.rb +82 -78
  107. data/test/test_object_tree.rb +25 -24
  108. data/test/test_pages.rb +43 -41
  109. data/test/test_pdf.rb +2 -0
  110. data/test/test_pdf_attachment.rb +23 -21
  111. data/test/test_pdf_create.rb +16 -15
  112. data/test/test_pdf_encrypt.rb +69 -66
  113. data/test/test_pdf_parse.rb +131 -129
  114. data/test/test_pdf_parse_lazy.rb +53 -53
  115. data/test/test_pdf_sign.rb +67 -67
  116. data/test/test_streams.rb +145 -143
  117. data/test/test_xrefs.rb +46 -45
  118. metadata +64 -8
@@ -1,144 +1,143 @@
1
- =begin
1
+ # frozen_string_literal: true
2
+
3
+ #
4
+ # This file is part of Origami, PDF manipulation framework for Ruby
5
+ # Copyright (C) 2016 Guillaume Delugré.
6
+ #
7
+ # Origami is free software: you can redistribute it and/or modify
8
+ # it under the terms of the GNU Lesser General Public License as published by
9
+ # the Free Software Foundation, either version 3 of the License, or
10
+ # (at your option) any later version.
11
+ #
12
+ # Origami is distributed in the hope that it will be useful,
13
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ # GNU Lesser General Public License for more details.
16
+ #
17
+ # You should have received a copy of the GNU Lesser General Public License
18
+ # along with Origami. If not, see <http://www.gnu.org/licenses/>.
19
+ #
2
20
 
3
- This file is part of Origami, PDF manipulation framework for Ruby
4
- Copyright (C) 2016 Guillaume Delugré.
21
+ module Origami
22
+ class PDF
23
+ #
24
+ # Returns true if the document behaves as a portfolio for embedded files.
25
+ #
26
+ def portfolio?
27
+ self.Catalog.Collection.is_a?(Dictionary)
28
+ end
29
+ end
5
30
 
6
- Origami is free software: you can redistribute it and/or modify
7
- it under the terms of the GNU Lesser General Public License as published by
8
- the Free Software Foundation, either version 3 of the License, or
9
- (at your option) any later version.
31
+ class Collection < Dictionary
32
+ include StandardObject
10
33
 
11
- Origami is distributed in the hope that it will be useful,
12
- but WITHOUT ANY WARRANTY; without even the implied warranty of
13
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
- GNU Lesser General Public License for more details.
34
+ module View
35
+ DETAILS = :D
36
+ TILE = :T
37
+ HIDDEN = :H
38
+ end
15
39
 
16
- You should have received a copy of the GNU Lesser General Public License
17
- along with Origami. If not, see <http://www.gnu.org/licenses/>.
40
+ class Schema < Dictionary
41
+ include StandardObject
18
42
 
19
- =end
43
+ field :Type, Type: Name, Default: :CollectionSchema
44
+ end
20
45
 
21
- module Origami
46
+ class Navigator < Dictionary
47
+ include StandardObject
48
+
49
+ module Type
50
+ FLEX = :Module
51
+ FLASH = :Default
52
+ end
53
+
54
+ field :SWF, Type: String, Required: true
55
+ field :Name, Type: String, Required: true
56
+ field :Desc, Type: String
57
+ field :Category, Type: String
58
+ field :ID, Type: String, Required: true
59
+ field :Version, Type: String
60
+ field :APIVersion, Type: String, Required: true
61
+ field :LoadType, Type: Name, Default: Type::FLASH
62
+ field :Icon, Type: String
63
+ field :Locale, Type: String
64
+ field :Strings, Type: NameTreeNode.of(String)
65
+ field :InitialFields, Type: Schema
66
+ field :Resources, Type: NameTreeNode.of(Stream), Required: true
67
+ end
22
68
 
23
- class PDF
24
- #
25
- # Returns true if the document behaves as a portfolio for embedded files.
26
- #
27
- def portfolio?
28
- self.Catalog.Collection.is_a?(Dictionary)
29
- end
69
+ class Color < Dictionary
70
+ include StandardObject
71
+
72
+ field :Background, Type: Array.of(Number, length: 3)
73
+ field :CardBackground, Type: Array.of(Number, length: 3)
74
+ field :CardBorder, Type: Array.of(Number, length: 3)
75
+ field :PrimaryText, Type: Array.of(Number, length: 3)
76
+ field :SecondaryText, Type: Array.of(Number, length: 3)
30
77
  end
31
78
 
32
- class Collection < Dictionary
33
- include StandardObject
34
-
35
- module View
36
- DETAILS = :D
37
- TILE = :T
38
- HIDDEN = :H
39
- end
40
-
41
- class Schema < Dictionary
42
- include StandardObject
43
-
44
- field :Type, :Type => Name, :Default => :CollectionSchema
45
- end
46
-
47
- class Navigator < Dictionary
48
- include StandardObject
49
-
50
- module Type
51
- FLEX = :Module
52
- FLASH = :Default
53
- end
54
-
55
- field :SWF, :Type => String, :Required => true
56
- field :Name, :Type => String, :Required => true
57
- field :Desc, :Type => String
58
- field :Category, :Type => String
59
- field :ID, :Type => String, :Required => true
60
- field :Version, :Type => String
61
- field :APIVersion, :Type => String, :Required => true
62
- field :LoadType, :Type => Name, :Default => Type::FLASH
63
- field :Icon, :Type => String
64
- field :Locale, :Type => String
65
- field :Strings, :Type => NameTreeNode.of(String)
66
- field :InitialFields, :Type => Schema
67
- field :Resources, :Type => NameTreeNode.of(Stream), :Required => true
68
- end
69
-
70
- class Color < Dictionary
71
- include StandardObject
72
-
73
- field :Background, :Type => Array.of(Number, length: 3)
74
- field :CardBackground, :Type => Array.of(Number, length: 3)
75
- field :CardBorder, :Type => Array.of(Number, length: 3)
76
- field :PrimaryText, :Type => Array.of(Number, length: 3)
77
- field :SecondaryText, :Type => Array.of(Number, length: 3)
78
- end
79
-
80
- class Split < Dictionary
81
- include StandardObject
82
-
83
- HORIZONTAL = :H
84
- VERTICAL = :V
85
- NONE = :N
86
-
87
- field :Direction, :Type => Name
88
- field :Position, :Type => Number
89
- end
90
-
91
- class Item < Dictionary
92
- include StandardObject
93
-
94
- field :Type, :Type => Name, :Default => :CollectionItem
95
- end
96
-
97
- class Subitem < Dictionary
98
- include StandardObject
99
-
100
- field :Type, :Type => Name, :Default => :CollectionSubitem
101
- field :D, :Type => [ String, Number ]
102
- field :P, :Type => String
103
- end
104
-
105
- class Folder < Dictionary
106
- include StandardObject
107
-
108
- field :Type, :Type => Name, :Default => :Folder
109
- field :ID, :Type => Integer, :Required => true
110
- field :Name, :Type => String, :Required => true
111
- field :Parent, :Type => Folder
112
- field :Child, :Type => Folder
113
- field :Next, :Type => Folder
114
- field :CI, :Type => Item
115
- field :Desc, :Type => String
116
- field :CreationDate, :Type => String
117
- field :ModDate, :Type => String
118
- field :Thumb, :Type => Stream
119
- field :Free, :Type => Array.of(Array.of(Integer, length: 2))
120
- end
121
-
122
- class Sort < Dictionary
123
- include StandardObject
124
-
125
- field :Type, :Type => Name, :Default => :CollectionSort
126
- field :S, :Type => [ Name, Array.of(Name) ]
127
- field :A, :Type => [ Boolean, Array.of(Boolean) ]
128
- end
129
-
130
- #
131
- # Collection fields.
132
- #
133
- field :Type, :Type => Name, :Default => :Collection
134
- field :Schema, :Type => Schema
135
- field :D, :Type => String
136
- field :View, :Type => Name, :Default => View::DETAILS
137
- field :Sort, :Type => Sort
138
- field :Navigator, :Type => Navigator, :ExtensionLevel => 3
139
- field :Resources, :Type => NameTreeNode.of(Stream), :ExtensionLevel => 3
140
- field :Colors, :Type => Color, :ExtensionLevel => 3
141
- field :Folders, :Type => Folder, :ExtensionLevel => 3
142
- field :Split, :Type => Split, :ExtensionLevel => 3
79
+ class Split < Dictionary
80
+ include StandardObject
81
+
82
+ HORIZONTAL = :H
83
+ VERTICAL = :V
84
+ NONE = :N
85
+
86
+ field :Direction, Type: Name
87
+ field :Position, Type: Number
143
88
  end
89
+
90
+ class Item < Dictionary
91
+ include StandardObject
92
+
93
+ field :Type, Type: Name, Default: :CollectionItem
94
+ end
95
+
96
+ class Subitem < Dictionary
97
+ include StandardObject
98
+
99
+ field :Type, Type: Name, Default: :CollectionSubitem
100
+ field :D, Type: [String, Number]
101
+ field :P, Type: String
102
+ end
103
+
104
+ class Folder < Dictionary
105
+ include StandardObject
106
+
107
+ field :Type, Type: Name, Default: :Folder
108
+ field :ID, Type: Integer, Required: true
109
+ field :Name, Type: String, Required: true
110
+ field :Parent, Type: Folder
111
+ field :Child, Type: Folder
112
+ field :Next, Type: Folder
113
+ field :CI, Type: Item
114
+ field :Desc, Type: String
115
+ field :CreationDate, Type: String
116
+ field :ModDate, Type: String
117
+ field :Thumb, Type: Stream
118
+ field :Free, Type: Array.of(Array.of(Integer, length: 2))
119
+ end
120
+
121
+ class Sort < Dictionary
122
+ include StandardObject
123
+
124
+ field :Type, Type: Name, Default: :CollectionSort
125
+ field :S, Type: [Name, Array.of(Name)]
126
+ field :A, Type: [Boolean, Array.of(Boolean)]
127
+ end
128
+
129
+ #
130
+ # Collection fields.
131
+ #
132
+ field :Type, Type: Name, Default: :Collection
133
+ field :Schema, Type: Schema
134
+ field :D, Type: String
135
+ field :View, Type: Name, Default: View::DETAILS
136
+ field :Sort, Type: Sort
137
+ field :Navigator, Type: Navigator, ExtensionLevel: 3
138
+ field :Resources, Type: NameTreeNode.of(Stream), ExtensionLevel: 3
139
+ field :Colors, Type: Color, ExtensionLevel: 3
140
+ field :Folders, Type: Folder, ExtensionLevel: 3
141
+ field :Split, Type: Split, ExtensionLevel: 3
142
+ end
144
143
  end
@@ -1,161 +1,157 @@
1
- =begin
2
-
3
- This file is part of Origami, PDF manipulation framework for Ruby
4
- Copyright (C) 2017 Guillaume Delugré.
5
-
6
- Origami is free software: you can redistribute it and/or modify
7
- it under the terms of the GNU Lesser General Public License as published by
8
- the Free Software Foundation, either version 3 of the License, or
9
- (at your option) any later version.
10
-
11
- Origami is distributed in the hope that it will be useful,
12
- but WITHOUT ANY WARRANTY; without even the implied warranty of
13
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
- GNU Lesser General Public License for more details.
15
-
16
- You should have received a copy of the GNU Lesser General Public License
17
- along with Origami. If not, see <http://www.gnu.org/licenses/>.
18
-
19
- =end
20
-
21
- require 'set'
1
+ # frozen_string_literal: true
2
+
3
+ #
4
+ # This file is part of Origami, PDF manipulation framework for Ruby
5
+ # Copyright (C) 2017 Guillaume Delugré.
6
+ #
7
+ # Origami is free software: you can redistribute it and/or modify
8
+ # it under the terms of the GNU Lesser General Public License as published by
9
+ # the Free Software Foundation, either version 3 of the License, or
10
+ # (at your option) any later version.
11
+ #
12
+ # Origami is distributed in the hope that it will be useful,
13
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ # GNU Lesser General Public License for more details.
16
+ #
17
+ # You should have received a copy of the GNU Lesser General Public License
18
+ # along with Origami. If not, see <http://www.gnu.org/licenses/>.
19
+ #
22
20
 
23
21
  module Origami
22
+ #
23
+ # Module for maintaining internal caches of objects for fast lookup.
24
+ #
25
+ module ObjectCache
26
+ attr_reader :strings_cache, :names_cache, :xref_cache
24
27
 
25
- #
26
- # Module for maintaining internal caches of objects for fast lookup.
27
- #
28
- module ObjectCache
29
- attr_reader :strings_cache, :names_cache, :xref_cache
30
-
31
- def initialize(*args)
32
- super(*args)
28
+ def initialize(*args)
29
+ super
33
30
 
34
- init_caches
35
- end
31
+ init_caches
32
+ end
36
33
 
37
- def rebuild_caches
38
- self.each do |*items|
39
- items.each do |object|
40
- object.rebuild_caches if object.is_a?(CompoundObject)
41
- cache_object(object)
42
- end
43
- end
34
+ def rebuild_caches
35
+ each do |*items|
36
+ items.each do |object|
37
+ object.rebuild_caches if object.is_a?(CompoundObject)
38
+ cache_object(object)
44
39
  end
40
+ end
41
+ end
45
42
 
46
- private
43
+ private
47
44
 
48
- def init_caches
49
- @strings_cache = Set.new
50
- @names_cache = Set.new
51
- @xref_cache = {}
52
- end
45
+ def init_caches
46
+ @strings_cache = Set.new
47
+ @names_cache = Set.new
48
+ @xref_cache = {}
49
+ end
53
50
 
54
- def cache_object(object)
55
- case object
56
- when String then cache_string(object)
57
- when Name then cache_name(object)
58
- when Reference then cache_reference(object)
59
- when CompoundObject then cache_compound(object)
60
- end
51
+ def cache_object(object)
52
+ case object
53
+ when String then cache_string(object)
54
+ when Name then cache_name(object)
55
+ when Reference then cache_reference(object)
56
+ when CompoundObject then cache_compound(object)
57
+ end
61
58
 
62
- object
63
- end
59
+ object
60
+ end
64
61
 
65
- def cache_compound(object)
66
- @strings_cache.merge(object.strings_cache)
67
- @names_cache.merge(object.names_cache)
68
- @xref_cache.update(object.xref_cache) do |_, cache1, cache2|
69
- cache1.concat(cache2)
70
- end
62
+ def cache_compound(object)
63
+ @strings_cache.merge(object.strings_cache)
64
+ @names_cache.merge(object.names_cache)
65
+ @xref_cache.update(object.xref_cache) do |_, cache1, cache2|
66
+ cache1.concat(cache2)
67
+ end
71
68
 
72
- object.strings_cache.clear
73
- object.names_cache.clear
74
- object.xref_cache.clear
75
- end
69
+ object.strings_cache.clear
70
+ object.names_cache.clear
71
+ object.xref_cache.clear
72
+ end
76
73
 
77
- def cache_string(str)
78
- @strings_cache.add(str)
79
- end
74
+ def cache_string(str)
75
+ @strings_cache.add(str)
76
+ end
80
77
 
81
- def cache_name(name)
82
- @names_cache.add(name)
83
- end
78
+ def cache_name(name)
79
+ @names_cache.add(name)
80
+ end
84
81
 
85
- def cache_reference(ref)
86
- @xref_cache[ref] ||= []
87
- @xref_cache[ref].push(self)
88
- end
82
+ def cache_reference(ref)
83
+ @xref_cache[ref] ||= []
84
+ @xref_cache[ref].push(self)
89
85
  end
86
+ end
87
+
88
+ #
89
+ # Module for objects containing other objects.
90
+ #
91
+ module CompoundObject
92
+ include Origami::Object
93
+ include ObjectCache
94
+ using TypeConversion
90
95
 
91
96
  #
92
- # Module for objects containing other objects.
97
+ # Returns true if the item is present in the compound object.
93
98
  #
94
- module CompoundObject
95
- include Origami::Object
96
- include ObjectCache
97
- using TypeConversion
98
-
99
- #
100
- # Returns true if the item is present in the compound object.
101
- #
102
- def include?(item)
103
- super(item.to_o)
104
- end
105
-
106
- #
107
- # Removes the item from the compound object if present.
108
- #
109
- def delete(item)
110
- obj = super(item.to_o)
111
- unlink_object(obj) unless obj.nil?
112
- end
99
+ def include?(item)
100
+ super(item.to_o)
101
+ end
113
102
 
114
- #
115
- # Creates a deep copy of the compound object.
116
- # This method can be quite expensive as nested objects are copied too.
117
- #
118
- def copy
119
- obj = self.update_values(&:copy)
103
+ #
104
+ # Removes the item from the compound object if present.
105
+ #
106
+ def delete(item)
107
+ obj = super(item.to_o)
108
+ unlink_object(obj) unless obj.nil?
109
+ end
120
110
 
121
- transfer_attributes(obj)
122
- end
111
+ #
112
+ # Creates a deep copy of the compound object.
113
+ # This method can be quite expensive as nested objects are copied too.
114
+ #
115
+ def copy
116
+ obj = update_values(&:copy)
123
117
 
124
- #
125
- # Returns a new compound object with updated values based on the provided block.
126
- #
127
- def update_values(&b)
128
- return enum_for(__method__) unless block_given?
129
- return self.class.new self.transform_values(&b) if self.respond_to?(:transform_values)
130
- return self.class.new self.map(&b) if self.respond_to?(:map)
118
+ transfer_attributes(obj)
119
+ end
131
120
 
132
- raise NotImplementedError, "This object does not implement this method"
133
- end
121
+ #
122
+ # Returns a new compound object with updated values based on the provided block.
123
+ #
124
+ def update_values(&b)
125
+ return enum_for(__method__) unless block_given?
126
+ return self.class.new transform_values(&b) if respond_to?(:transform_values)
127
+ return self.class.new map(&b) if respond_to?(:map)
134
128
 
135
- #
136
- # Modifies the compound object's values based on the provided block.
137
- #
138
- def update_values!(&b)
139
- return enum_for(__method__) unless block_given?
140
- return self.transform_values!(&b) if self.respond_to?(:transform_values!)
141
- return self.map!(&b) if self.respond_to?(:map!)
129
+ raise NotImplementedError, "This object does not implement this method"
130
+ end
142
131
 
143
- raise NotImplementedError, "This object does not implement this method"
144
- end
132
+ #
133
+ # Modifies the compound object's values based on the provided block.
134
+ #
135
+ def update_values!(&b)
136
+ return enum_for(__method__) unless block_given?
137
+ return transform_values!(&b) if respond_to?(:transform_values!)
138
+ return map!(&b) if respond_to?(:map!)
145
139
 
146
- private
140
+ raise NotImplementedError, "This object does not implement this method"
141
+ end
147
142
 
148
- def link_object(item)
149
- obj = item.to_o
150
- obj.parent = self unless obj.indirect?
143
+ private
151
144
 
152
- cache_object(obj)
153
- end
145
+ def link_object(item)
146
+ obj = item.to_o
147
+ obj.parent = self unless obj.indirect?
154
148
 
155
- def unlink_object(obj)
156
- obj.parent = nil
157
- obj
158
- end
149
+ cache_object(obj)
159
150
  end
160
151
 
152
+ def unlink_object(obj)
153
+ obj.parent = nil
154
+ obj
155
+ end
156
+ end
161
157
  end