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
A new instance of Bound.
-
#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.
Returns a new instance of Bound.
3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 |
# File 'lib/git/commands/arguments.rb', line 3202 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.
3194 3195 3196 |
# File 'lib/git/commands/arguments.rb', line 3194 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.
3246 3247 3248 3249 3250 3251 |
# File 'lib/git/commands/arguments.rb', line 3246 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.
3235 3236 3237 |
# File 'lib/git/commands/arguments.rb', line 3235 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.
3223 3224 3225 |
# File 'lib/git/commands/arguments.rb', line 3223 def to_ary @args_array end |