Class: Servactory::TestKit::Rspec::Matchers::Base::SubmatcherRegistry::SubmatcherDefinition
- Inherits:
-
Object
- Object
- Servactory::TestKit::Rspec::Matchers::Base::SubmatcherRegistry::SubmatcherDefinition
- Defined in:
- lib/servactory/test_kit/rspec/matchers/base/submatcher_registry.rb
Overview
Value object holding configuration for a single submatcher registration.
## Purpose
Encapsulates all configuration options for a submatcher, including how to generate chain methods, transform arguments, and handle mutual exclusivity with other submatchers.
## Attributes
-
‘name` - Unique identifier for this submatcher
-
‘class_name` - Relative path to submatcher class
-
‘chain_method` - Name of the fluent API method
-
‘chain_aliases` - Alternative method names
-
‘transform_args` - Lambda for argument transformation
-
‘requires_option_types` - Whether submatcher needs type information
-
‘requires_last_submatcher` - Whether submatcher needs previous submatcher
-
‘mutually_exclusive_with` - Conflicting submatcher names
-
‘stores_option_types` - Whether to store args as option_types
-
‘accepts_trailing_options` - Whether to extract trailing hash
Instance Attribute Summary collapse
-
#accepts_trailing_options ⇒ Boolean
readonly
Whether to extract trailing hash as options.
-
#chain_aliases ⇒ Array<Symbol>
readonly
Alternative method names.
-
#chain_method ⇒ Symbol
readonly
Method name for the fluent API.
-
#class_name ⇒ String
readonly
Relative class path (e.g., “Input::RequiredSubmatcher”).
-
#mutually_exclusive_with ⇒ Array<Symbol>
readonly
Names of mutually exclusive submatchers.
-
#name ⇒ Symbol
readonly
Unique identifier for this submatcher.
-
#requires_last_submatcher ⇒ Boolean
readonly
Whether submatcher needs last_submatcher in context.
-
#requires_option_types ⇒ Boolean
readonly
Whether submatcher needs option_types in context.
-
#stores_option_types ⇒ Boolean
readonly
Whether to store transformed args as option_types.
-
#transform_args ⇒ Proc
readonly
Lambda to transform arguments.
Instance Method Summary collapse
-
#initialize(name:, class_name:, chain_method: nil, chain_aliases: nil, transform_args: nil, requires_option_types: false, requires_last_submatcher: false, mutually_exclusive_with: nil, stores_option_types: false, accepts_trailing_options: false) ⇒ SubmatcherDefinition
constructor
Creates a new submatcher definition.
Constructor Details
#initialize(name:, class_name:, chain_method: nil, chain_aliases: nil, transform_args: nil, requires_option_types: false, requires_last_submatcher: false, mutually_exclusive_with: nil, stores_option_types: false, accepts_trailing_options: false) ⇒ SubmatcherDefinition
Creates a new submatcher definition.
176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 |
# File 'lib/servactory/test_kit/rspec/matchers/base/submatcher_registry.rb', line 176 def initialize( name:, class_name:, chain_method: nil, chain_aliases: nil, transform_args: nil, requires_option_types: false, requires_last_submatcher: false, mutually_exclusive_with: nil, stores_option_types: false, accepts_trailing_options: false ) @name = name @class_name = class_name @chain_method = chain_method @chain_aliases = chain_aliases @transform_args = transform_args @requires_option_types = requires_option_types @requires_last_submatcher = requires_last_submatcher @mutually_exclusive_with = mutually_exclusive_with @stores_option_types = stores_option_types @accepts_trailing_options = end |
Instance Attribute Details
#accepts_trailing_options ⇒ Boolean (readonly)
Returns Whether to extract trailing hash as options.
162 163 164 |
# File 'lib/servactory/test_kit/rspec/matchers/base/submatcher_registry.rb', line 162 def @accepts_trailing_options end |
#chain_aliases ⇒ Array<Symbol> (readonly)
Returns Alternative method names.
144 145 146 |
# File 'lib/servactory/test_kit/rspec/matchers/base/submatcher_registry.rb', line 144 def chain_aliases @chain_aliases end |
#chain_method ⇒ Symbol (readonly)
Returns Method name for the fluent API.
141 142 143 |
# File 'lib/servactory/test_kit/rspec/matchers/base/submatcher_registry.rb', line 141 def chain_method @chain_method end |
#class_name ⇒ String (readonly)
Returns Relative class path (e.g., “Input::RequiredSubmatcher”).
138 139 140 |
# File 'lib/servactory/test_kit/rspec/matchers/base/submatcher_registry.rb', line 138 def class_name @class_name end |
#mutually_exclusive_with ⇒ Array<Symbol> (readonly)
Returns Names of mutually exclusive submatchers.
156 157 158 |
# File 'lib/servactory/test_kit/rspec/matchers/base/submatcher_registry.rb', line 156 def mutually_exclusive_with @mutually_exclusive_with end |
#name ⇒ Symbol (readonly)
Returns Unique identifier for this submatcher.
135 136 137 |
# File 'lib/servactory/test_kit/rspec/matchers/base/submatcher_registry.rb', line 135 def name @name end |
#requires_last_submatcher ⇒ Boolean (readonly)
Returns Whether submatcher needs last_submatcher in context.
153 154 155 |
# File 'lib/servactory/test_kit/rspec/matchers/base/submatcher_registry.rb', line 153 def requires_last_submatcher @requires_last_submatcher end |
#requires_option_types ⇒ Boolean (readonly)
Returns Whether submatcher needs option_types in context.
150 151 152 |
# File 'lib/servactory/test_kit/rspec/matchers/base/submatcher_registry.rb', line 150 def requires_option_types @requires_option_types end |
#stores_option_types ⇒ Boolean (readonly)
Returns Whether to store transformed args as option_types.
159 160 161 |
# File 'lib/servactory/test_kit/rspec/matchers/base/submatcher_registry.rb', line 159 def stores_option_types @stores_option_types end |
#transform_args ⇒ Proc (readonly)
Returns Lambda to transform arguments.
147 148 149 |
# File 'lib/servactory/test_kit/rspec/matchers/base/submatcher_registry.rb', line 147 def transform_args @transform_args end |