From b28d423db659a895b6d94d2c6e5800b7eeea55a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Iv=C3=A1n=20L=C3=B3pez=20Gonz=C3=A1lez?= Date: Thu, 17 Aug 2023 12:46:51 +0100 Subject: [PATCH] Code style --- .../proposal_settings_conversion/from_dbus.rb | 6 +-- .../storage/volume_conversion/from_dbus.rb | 6 +-- .../dbus/storage/volume_conversion/to_dbus.rb | 41 ++++++++++--------- 3 files changed, 27 insertions(+), 26 deletions(-) diff --git a/service/lib/agama/dbus/storage/proposal_settings_conversion/from_dbus.rb b/service/lib/agama/dbus/storage/proposal_settings_conversion/from_dbus.rb index 0b307ee0a4..a2d6c09281 100644 --- a/service/lib/agama/dbus/storage/proposal_settings_conversion/from_dbus.rb +++ b/service/lib/agama/dbus/storage/proposal_settings_conversion/from_dbus.rb @@ -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 diff --git a/service/lib/agama/dbus/storage/volume_conversion/from_dbus.rb b/service/lib/agama/dbus/storage/volume_conversion/from_dbus.rb index 5a19a46bcf..33d87e3bd8 100644 --- a/service/lib/agama/dbus/storage/volume_conversion/from_dbus.rb +++ b/service/lib/agama/dbus/storage/volume_conversion/from_dbus.rb @@ -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 diff --git a/service/lib/agama/dbus/storage/volume_conversion/to_dbus.rb b/service/lib/agama/dbus/storage/volume_conversion/to_dbus.rb index bfa409aba7..a15e4ace13 100644 --- a/service/lib/agama/dbus/storage/volume_conversion/to_dbus.rb +++ b/service/lib/agama/dbus/storage/volume_conversion/to_dbus.rb @@ -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, @@ -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?,