Class: Cuprum::Utils::ParametersMapping
- Parent Namespace
- Cuprum::Utils
- Defined In
- lib/cuprum/utils/parameters_mapping.rb
Table Of Contents
Overview
Utility class mapping a method’s parameters by parameter name.
Back To Top
Class Methods
.build(callable) => ParametersMapping
Generates a parameters mapping for the given method or Proc.
Parameters
- callable (#parameters) — the method or Proc for which to map
parameters.
Returns
- (ParametersMapping) — the mapping for the callable object.
Back To Top
Constructor
#initialize(arguments: [], keywords: [], block: nil, variadic_arguments: nil, variadic_keywords: nil) => ParametersMapping
Parameters
- arguments (Array<Symbol>) — the named arguments to the method, both
required and optional, but excluding variadic args).
- block (Symbol, nil) — the name of the block parameter, if any.
- keywords (Array<Symbol>) — the keywords for the method, both
required and optional, but excluding variadic keywords.
- variadic_arguments (Symbol) — the name of the variadic arguments
parameter, if any.
- variadic_keywords (Symbol) — the name of the variadic keywords
parameter, if any.
Returns
- (ParametersMapping) — a new instance of ParametersMapping
Back To Top
Instance Attributes
#arguments => Hash{Symbol => Integer} (readonly)
Returns
- (Hash{Symbol => Integer}) — the named arguments to the method, both
required and optional, but excluding variadic args).
#block => Symbol, nil (readonly)
Returns
- (Symbol, nil) — the name of the block parameter, if any.
#keywords => Set<Symbol> (readonly)
Returns
- (Set<Symbol>) — the keywords for the method, both required and
optional, but excluding variadic keywords.
#variadic_arguments => Symbol (readonly)
Returns
- (Symbol) — the name of the variadic arguments parameter, if any.
#variadic_keywords => Symbol (readonly)
Returns
- (Symbol) — the name of the variadic keywords parameter, if any.
Back To Top
Instance Methods
#arguments_count => Integer
Returns
- (Integer) — the number of named arguments.
#block? => true, false
Returns
- (true, false) — true if the method has a block parameter; otherwise
false.
#call(*arguments, **keywords, &block) => Hash{Symbol => Object}
Maps the given parameters to a Hash of parameter names and values.
Parameters
- arguments (Array) — the positional parameters to map.
- keywords (Hash) — the keyword parameters to map.
- block (Proc) — the block parameter to map, if any.
Returns
- (Hash{Symbol => Object}) — the mapped parameters.
#variadic_arguments? => true, false
Returns
- (true, false) — true if the method has a variadic arguments
parameter; otherwise false.
#variadic_keywords? => true, false
Returns
- (true, false) — true if the method has a variadic keywords
parameter; otherwise false.
Back To Top
Back to
Documentation |
Reference
|
Cuprum
|
Cuprum::Utils