Module: RubyGit::OptionValidators

Included in:
Worktree, Worktree
Defined in:
lib/ruby_git/option_validators.rb

Overview

Module containing option validators for RubyGit

Instance Method Summary collapse

Instance Method Details

#validate_boolean_option(name:, value:, nullable: false)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

This method returns an undefined value.

Raise an error if an option is not a Boolean (or optionally nil) value

Parameters:

  • name (String)

    the name of the option

  • value (Object)

    the value of the option

  • nullable (Boolean) (defaults to: false)

    whether the option can be nil (default is false)

Raises:

  • (ArgumentError)

    if the option is not a Boolean (or optionally nil) value



14
15
16
17
18
19
20
# File 'lib/ruby_git/option_validators.rb', line 14

def validate_boolean_option(name:, value:, nullable: false)
  return if nullable && value.nil?

  return if [true, false].include?(value)

  raise ArgumentError, "The '#{name}:' option must be a Boolean value but was #{value.inspect}"
end

#validate_string_option(name:, value:, nullable: false)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

This method returns an undefined value.

Raise an error if an option is not a String (or optionally nil) value

Parameters:

  • name (String)

    the name of the option

  • value (Object)

    the value of the option

  • nullable (Boolean) (defaults to: false)

    whether the option can be nil (default is false)

Raises:

  • (ArgumentError)

    if the option is not a String (or optionally nil) value



29
30
31
32
33
34
35
# File 'lib/ruby_git/option_validators.rb', line 29

def validate_string_option(name:, value:, nullable: false)
  return if nullable && value.nil?

  return if value.is_a?(String)

  raise ArgumentError, "The '#{name}:' option must be a String or nil but was #{value.inspect}"
end