Module: RubyXL::RelationshipSupport
- Included in:
- ChartFile, Chartsheet, DrawingFile, Workbook, WorkbookRoot, Worksheet
- Defined in:
- lib/rubyXL/objects/relationships.rb
Defined Under Namespace
Modules: ClassMehods
Instance Attribute Summary collapse
-
#generic_storage ⇒ Object
Returns the value of attribute generic_storage.
-
#relationship_container ⇒ Object
Returns the value of attribute relationship_container.
Class Method Summary collapse
Instance Method Summary collapse
- #attach_relationship(rid, rf) ⇒ Object
- #collect_related_objects ⇒ Object
- #load_relationships(dir_path, base_file_name) ⇒ Object
-
#related_objects ⇒ Object
Override this method.
- #store_relationship(related_file, unknown = false) ⇒ Object
Instance Attribute Details
#generic_storage ⇒ Object
Returns the value of attribute generic_storage.
148 149 150 |
# File 'lib/rubyXL/objects/relationships.rb', line 148 def generic_storage @generic_storage end |
#relationship_container ⇒ Object
Returns the value of attribute relationship_container.
148 149 150 |
# File 'lib/rubyXL/objects/relationships.rb', line 148 def relationship_container @relationship_container end |
Class Method Details
.included(klass) ⇒ Object
143 144 145 146 |
# File 'lib/rubyXL/objects/relationships.rb', line 143 def self.included(klass) klass.class_variable_set(:@@ooxml_relationships, {}) klass.extend RubyXL::RelationshipSupport::ClassMehods end |
Instance Method Details
#attach_relationship(rid, rf) ⇒ Object
177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 |
# File 'lib/rubyXL/objects/relationships.rb', line 177 def attach_relationship(rid, rf) relationships = self.class.class_variable_get(:@@ooxml_relationships) klass = rf.class if relationships.has_key?(klass) then accessor = relationships[klass] case accessor when NilClass then # Relationship is known, but we don't have a special accessor for it, store as generic store_relationship(rf) when false then # Do nothing, the code will perform attaching on its own else container = self.send(accessor) if container.is_a?(Array) then container << rf else self.send("#{accessor}=", rf) end end else store_relationship(rf, :unknown) end end |
#collect_related_objects ⇒ Object
154 155 156 157 158 159 160 161 162 163 164 165 166 |
# File 'lib/rubyXL/objects/relationships.rb', line 154 def res = .compact # Avoid tainting +related_objects+ array res += generic_storage if generic_storage if relationship_container then relationship_container.owner = self res << relationship_container end res.each { |o| res += o. if o.respond_to?(:collect_related_objects) } res end |
#load_relationships(dir_path, base_file_name) ⇒ Object
168 169 170 171 172 173 174 175 |
# File 'lib/rubyXL/objects/relationships.rb', line 168 def load_relationships(dir_path, base_file_name) self.relationship_container = RubyXL::OOXMLRelationshipsFile.load_relationship_file(dir_path, base_file_name) return if relationship_container.nil? relationship_container.(dir_path, base_file_name).each_pair { |rid, | attach_relationship(rid, ) if } end |
#related_objects ⇒ Object
Override this method
150 151 152 |
# File 'lib/rubyXL/objects/relationships.rb', line 150 def # Override this method [] end |
#store_relationship(related_file, unknown = false) ⇒ Object
198 199 200 201 202 |
# File 'lib/rubyXL/objects/relationships.rb', line 198 def store_relationship(, unknown = false) self.generic_storage ||= [] puts "WARNING: #{self.class} is not aware what to do with #{.class}" if unknown self.generic_storage << end |