Module: Goldendocx::HasAssociations
- Extended by:
- ActiveSupport::Concern
- Included in:
- Docx, Parts::Documents
- Defined in:
- lib/goldendocx/has_associations.rb
Constant Summary collapse
- Options =
Data.define(:class_name, :isolate)
Instance Method Summary collapse
- #read_associations(docx_file) ⇒ Object
- #read_relationships(docx_file) ⇒ Object
- #relationships ⇒ Object
- #write_relationships(zos) ⇒ Object
Instance Method Details
#read_associations(docx_file) ⇒ Object
34 35 36 37 38 39 40 |
# File 'lib/goldendocx/has_associations.rb', line 34 def read_associations(docx_file) associations.each do |association, | association_class = .class_name.constantize association_document_xml = docx_file.read(association_class::XML_PATH) instance_variable_set("@#{association}", association_class.parse(association_document_xml)) end end |
#read_relationships(docx_file) ⇒ Object
42 43 44 |
# File 'lib/goldendocx/has_associations.rb', line 42 def read_relationships(docx_file) @relationships = Goldendocx::Models::Relationships.parse(docx_file.read(relationships_xml_path)) end |
#relationships ⇒ Object
50 51 52 |
# File 'lib/goldendocx/has_associations.rb', line 50 def relationships @relationships ||= Goldendocx::Models::Relationships.new end |
#write_relationships(zos) ⇒ Object
46 47 48 |
# File 'lib/goldendocx/has_associations.rb', line 46 def write_relationships(zos) relationships.write_to(zos, relationships_xml_path) end |