Module: OpenXml::HasProperties

Defined in:
lib/openxml/has_properties.rb

Defined Under Namespace

Modules: ClassMethods Classes: ChoiceGroupUniqueError

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



6
7
8
# File 'lib/openxml/has_properties.rb', line 6

def self.included(base)
  base.extend ClassMethods
end

Instance Method Details

#properties_attributesObject



117
118
119
# File 'lib/openxml/has_properties.rb', line 117

def properties_attributes
  properties_element.attributes
end

#properties_elementObject



113
114
115
# File 'lib/openxml/has_properties.rb', line 113

def properties_element
  @properties_element ||= self.class.properties_element.new
end

#property_xml(xml) ⇒ Object



133
134
135
136
137
138
139
140
# File 'lib/openxml/has_properties.rb', line 133

def property_xml(xml)
  props = active_properties
  return unless render_properties? props

  properties_element.to_xml(xml) do
    props.each { |prop| prop.to_xml(xml) }
  end
end

#render?Boolean

Returns:

  • (Boolean)


121
122
123
124
# File 'lib/openxml/has_properties.rb', line 121

def render?
  return true unless defined?(super)
  render_properties? || super
end

#to_xml(xml) ⇒ Object



126
127
128
129
130
131
# File 'lib/openxml/has_properties.rb', line 126

def to_xml(xml)
  super(xml) do
    property_xml(xml)
    yield xml if block_given?
  end
end