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
8
9
10
|
# File 'lib/openxml/has_properties.rb', line 8
def self.included(base)
base.extend ClassMethods
end
|
Instance Method Details
#build_required_properties ⇒ Object
157
158
159
160
161
162
|
# File 'lib/openxml/has_properties.rb', line 157
def build_required_properties
required_properties.each do |prop, default_value|
public_send(:"#{prop}=", default_value) if respond_to? :"#{prop}="
public_send(:"#{prop}")
end
end
|
#initialize(*_args) ⇒ Object
122
123
124
125
|
# File 'lib/openxml/has_properties.rb', line 122
def initialize(*_args)
super
build_required_properties
end
|
#properties_attributes ⇒ Object
131
132
133
|
# File 'lib/openxml/has_properties.rb', line 131
def properties_attributes
properties_element.attributes
end
|
#properties_element ⇒ Object
127
128
129
|
# File 'lib/openxml/has_properties.rb', line 127
def properties_element
@properties_element ||= self.class.properties_element.new
end
|
#property_xml(xml) ⇒ Object
147
148
149
150
151
152
153
154
155
|
# File 'lib/openxml/has_properties.rb', line 147
def property_xml(xml)
ensure_required_choices
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
135
136
137
138
|
# File 'lib/openxml/has_properties.rb', line 135
def render?
return true unless defined?(super)
render_properties? || super
end
|
#to_xml(xml) ⇒ Object
140
141
142
143
144
145
|
# File 'lib/openxml/has_properties.rb', line 140
def to_xml(xml)
super(xml) do
property_xml(xml)
yield xml if block_given?
end
end
|