Module: RubyXL::RelationshipSupport

Included in:
ChartFile, Chartsheet, DrawingFile, Workbook, WorkbookRoot, Worksheet
Defined in:
lib/rubyXL/objects/relationships.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#generic_storageObject

Returns the value of attribute generic_storage.



179
180
181
# File 'lib/rubyXL/objects/relationships.rb', line 179

def generic_storage
  @generic_storage
end

#relationship_containerObject

Returns the value of attribute relationship_container.



179
180
181
# File 'lib/rubyXL/objects/relationships.rb', line 179

def relationship_container
  @relationship_container
end

Instance Method Details



184
185
186
187
188
189
190
191
192
193
194
195
196
197
# File 'lib/rubyXL/objects/relationships.rb', line 184

def collect_related_objects
  res = related_objects.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.collect_related_objects if o.respond_to?(:collect_related_objects) }

  res
end

#load_relationships(dir_path, base_file_name = '') ⇒ Object



205
206
207
208
209
210
211
212
# File 'lib/rubyXL/objects/relationships.rb', line 205

def load_relationships(dir_path, base_file_name = '')
  self.relationship_container = relationship_file_class.load_relationship_file(dir_path, base_file_name)
  return if relationship_container.nil?

  relationship_container.load_related_files(dir_path, base_file_name).each_pair { |rid, related_file|
    attach_relationship(rid, related_file) if related_file
  }
end

Override this method



180
181
182
# File 'lib/rubyXL/objects/relationships.rb', line 180

def related_objects # Override this method
  []
end

#store_relationship(related_file, unknown = false) ⇒ Object



199
200
201
202
203
# File 'lib/rubyXL/objects/relationships.rb', line 199

def store_relationship(related_file, unknown = false)
  self.generic_storage ||= []
  puts "WARNING: #{self.class} is not aware what to do with #{related_file.class}" if unknown
  self.generic_storage << related_file
end