Skip to content

Commit

Permalink
Move to inline settings validations
Browse files Browse the repository at this point in the history
This makes it clearer how the setting is exactly defined. As a bonus,
this syntax is compatible with both Ruby 2 and 3.
  • Loading branch information
ekohl committed Feb 12, 2024
1 parent 8cc4e19 commit 5e64c82
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions lib/foreman_discovery/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,10 @@ class Engine < ::Rails::Engine
setting "discovery_hostname",
type: :array,
default: ["discovery_bootif"],
validate: { presence: true },
full_name: N_("Hostname facts"),
description: N_("List of facts to use for the hostname (first wins)")

validates "discovery_hostname", presence: true

setting "discovery_auto",
type: :boolean,
default: false,
Expand All @@ -95,11 +94,10 @@ class Engine < ::Rails::Engine
setting "discovery_prefix",
type: :string,
default: "mac",
validate: { presence: true },
full_name: N_("Hostname prefix"),
description: N_("The default prefix to use for the host name, must start with a letter")

validates "discovery_prefix", presence: true

setting "discovery_fact_column",
type: :array,
default: [],
Expand Down

0 comments on commit 5e64c82

Please sign in to comment.