Skip to content

Commit ef380f8

Browse files
committed
Refactor volume#to_xml to please RuboCop
Fixes: 476c630 ("Always use XML builders to construct XML")
1 parent 476c630 commit ef380f8

File tree

1 file changed

+11
-14
lines changed

1 file changed

+11
-14
lines changed

lib/fog/libvirt/models/compute/volume.rb

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -92,26 +92,14 @@ def to_xml
9292

9393
xml.target do
9494
xml.format(:type => format_type)
95-
96-
xml.permissions do
97-
xml.owner(owner) if owner
98-
xml.group(group) if group
99-
xml.mode('0744')
100-
xml.label('virt_image_t')
101-
end
95+
xml_permissions(xml)
10296
end
10397

10498
if backing_volume
10599
xml.backingStore do
106100
xml.path(backing_volume.path)
107101
xml.format(:type => backing_volume.format_type)
108-
109-
xml.permissions do
110-
xml.owner(owner) if owner
111-
xml.group(group) if group
112-
xml.mode('0744')
113-
xml.label('virt_image_t')
114-
end
102+
xml_permissions(xml)
115103
end
116104
end
117105
end
@@ -122,6 +110,15 @@ def to_xml
122110

123111
private
124112

113+
def xml_permissions(xml)
114+
xml.permissions do
115+
xml.owner(owner) if owner
116+
xml.group(group) if group
117+
xml.mode('0744')
118+
xml.label('virt_image_t')
119+
end
120+
end
121+
125122
def image_suffix
126123
return "img" if format_type == "raw"
127124
format_type

0 commit comments

Comments
 (0)