Class: Git::Commands::Arguments::Bound Private
- Inherits:
-
Object
- Object
- Git::Commands::Arguments::Bound
- Defined in:
- lib/git/commands/arguments.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Bound arguments object returned by #bind
Provides accessor methods for all defined options and positional arguments, with automatic normalization of aliases to their canonical names.
For every flag_option, both a plain accessor (e.g. bound.force) and a
?-suffixed predicate alias (e.g. bound.force?) are generated, following
Ruby convention for boolean predicates. Plain accessors are kept for backward
compatibility. value_option fields only receive plain accessors.
Reserved-name exception: if the ?-suffixed name conflicts with a name
in RESERVED_NAMES (e.g. nil?, frozen?), the predicate alias is not
generated to avoid overriding built-in Object methods. Use hash-style
access (bound[:nil]) when the flag name is reserved.
Constant Summary collapse
- RESERVED_NAMES =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Names that cannot have accessor methods defined (would override Object methods)
(Object.instance_methods + [:to_ary]).freeze
- EMPTY_EXECUTION_OPTIONS =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Canonical frozen empty hash returned by #execution_options when no non-nil execution options are present.
{}.freeze
Instance Attribute Summary collapse
-
#execution_options ⇒ Hash{Symbol => Object}
readonly
private
Execution options and values for command execution.
Instance Method Summary collapse
-
#[](key) ⇒ Object?
private
Hash-style access to option and positional values.
-
#initialize(args_array, options, positionals, execution_option_names = [], flag_names = []) ⇒ Bound
constructor
private
Initialize a new frozen Bound object with accessor methods for all defined arguments.
-
#to_a ⇒ Array<String>
private
Returns the CLI arguments array for splatting.
-
#to_ary ⇒ Array<String>
private
Returns the CLI arguments array for splatting.
Constructor Details
#initialize(args_array, options, positionals, execution_option_names = [], flag_names = []) ⇒ Bound
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.
Initialize a new frozen Bound object with accessor methods for all defined arguments
4037 4038 4039 4040 4041 4042 4043 4044 4045 4046 4047 4048 4049 |
# File 'lib/git/commands/arguments.rb', line 4037 def initialize(args_array, , positionals, execution_option_names = [], flag_names = []) @args_array = args_array.freeze @options = .freeze @positionals = positionals.freeze @execution_options = (execution_option_names) # Define accessor methods (skip reserved names) @options.each_key { |name| define_accessor(name, @options) } @positionals.each_key { |name| define_accessor(name, @positionals) } define_flag_predicate_accessors(flag_names) freeze end |
Instance Attribute Details
#execution_options ⇒ Hash{Symbol => Object} (readonly)
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.
Execution options and values for command execution.
Includes only options declared via Git::Commands::Arguments#execution_option and excludes options with nil values.
4021 4022 4023 |
# File 'lib/git/commands/arguments.rb', line 4021 def @execution_options end |
Instance Method Details
#[](key) ⇒ Object?
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.
Hash-style access to option and positional values
Use this for reserved names (like :hash, :class) that cannot have accessor methods defined.
4082 4083 4084 4085 4086 4087 |
# File 'lib/git/commands/arguments.rb', line 4082 def [](key) return @options[key] if @options.key?(key) return @positionals[key] if @positionals.key?(key) nil end |
#to_a ⇒ Array<String>
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.
Returns the CLI arguments array for splatting
Ruby's splat operator in array literals uses to_a for expansion.
This enables: ['git', 'branch', *bound_args].
Operands declared with skip_cli: true are intentionally excluded.
4070 4071 4072 |
# File 'lib/git/commands/arguments.rb', line 4070 def to_a @args_array end |
#to_ary ⇒ Array<String>
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.
Returns the CLI arguments array for splatting
This enables direct splatting: command(*bound_args).
Operands declared with skip_cli: true are intentionally excluded.
4058 4059 4060 |
# File 'lib/git/commands/arguments.rb', line 4058 def to_ary @args_array end |