Skip to content

Commit

Permalink
Code style
Browse files Browse the repository at this point in the history
  • Loading branch information
joseivanlopez committed Aug 17, 2023
1 parent 5db39de commit b28d423
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ def convert

settings.tap do |target|
dbus_settings.each do |dbus_property, dbus_value|
meth = CONVERSIONS[dbus_property]
converter = CONVERSIONS[dbus_property]
# FIXME: likely ignoring the wrong attribute is not the best
next unless meth
next unless converter

send(meth, target, dbus_value)
send(converter, target, dbus_value)
end
end
end
Expand Down
6 changes: 3 additions & 3 deletions service/lib/agama/dbus/storage/volume_conversion/from_dbus.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ def convert

volume.tap do |target|
dbus_volume.each do |dbus_property, dbus_value|
meth = CONVERSIONS[dbus_property]
converter = CONVERSIONS[dbus_property]
# FIXME: likely ignoring the wrong attribute is not the best
next unless meth
next unless converter

send(meth, target, dbus_value)
send(converter, target, dbus_value)
end
end
end
Expand Down
41 changes: 21 additions & 20 deletions service/lib/agama/dbus/storage/volume_conversion/to_dbus.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,6 @@ def initialize(volume)
#
# @return [Hash]
def convert
hash = base_conversion
return hash if volume.max_size.nil? || volume.max_size.unlimited?

hash["MaxSize"] = volume.max_size.to_i
hash
end

private

# @return [Agama::Storage::Volume]
attr_reader :volume

# @return [Hash]
def base_conversion
{
"MountPath" => volume.mount_path.to_s,
"MountOptions" => volume.mount_options,
Expand All @@ -56,15 +42,30 @@ def base_conversion
"FsType" => volume.fs_type&.to_human_string || "",
"MinSize" => volume.min_size&.to_i,
"AutoSize" => volume.auto_size?,
"Snapshots" => volume.btrfs.snapshots?,
"Outline" => outline_conversion
}
"Snapshots" => volume.btrfs.snapshots?
}.tap do |target|
max_size_conversion(target)
outline_conversion(target)
end
end

# @return [Hash]
def outline_conversion
private

# @return [Agama::Storage::Volume]
attr_reader :volume

# @param target [Hash]
def max_size_conversion(target)
return if volume.max_size.nil? || volume.max_size.unlimited?

target["MaxSize"] = volume.max_size.to_i
end

# @param target [Hash]
def outline_conversion(target)
outline = volume.outline
{

target["Outline"] = {
"Required" => outline.required?,
"FsTypes" => outline.filesystems.map(&:to_human_string),
"SupportAutoSize" => outline.adaptive_sizes?,
Expand Down

0 comments on commit b28d423

Please sign in to comment.