Locate types.
# File lib/aquarium/finders/type_finder.rb, line 26 def self.add_ancestors_descendents_and_nested_option_variants_for option, options_hash all_variants = options_hash[option].dup %w[descendents ancestors nested_types].each do |suffix| options_hash["#{option}_and_#{suffix}"] = all_variants.inject([]) do |memo, x| memo << "#{x}_and_#{suffix}" << "#{x}_and_#{suffix}_of" end end options_hash["#{option}_and_nested_types"] += all_variants.map {|x| "#{x}_and_nested"} end
Returns a TypeFinder::TypeFinderResult, where the “matched” keys are the input types, type names, and/or regular expressions, and objects for which matches were found and the corresponding values are the class constant or variable pointcuts that were found. The keys in the “not_matched” part of the result are the specified types and objects for which no matches were found.
The options are as follows:
A single type, type name, name regular expression, or an array of the same. (Mixed allowed.)
:types => types_and_type_names_and_regexps
:names => types_and_type_names_and_regexps
:type => types_and_type_names_and_regexps
:name => types_and_type_names_and_regexps
A single type, type name, name regular expression, or an array of the same. (Mixed allowed.) Matching types and their descendents will be found. A type that includes a module is considered a descendent, since the module would show up in that type’s ancestors.
:types_and_descendents => types_and_type_names_and_regexps
:names_and_descendents => types_and_type_names_and_regexps
:type_and_descendents => types_and_type_names_and_regexps
:name_and_descendents => types_and_type_names_and_regexps
You can also append the suffix “_of” on any of these keys.
A single type, type name, name regular expression, or an array of the same. (Mixed allowed.) Matching types and their ancestors will be found.
:types_and_ancestors => types_and_type_names_and_regexps
:names_and_ancestors => types_and_type_names_and_regexps
:type_and_ancestors => types_and_type_names_and_regexps
:name_and_ancestors => types_and_type_names_and_regexps
You can also append the suffix “_of” on any of these keys.
A single type, type name, name regular expression, or an array of the same. (Mixed allowed.) Matching types and any types nested within them will be found.
:types_and_nested_types => types_and_type_names_and_regexps
:names_and_nested_types => types_and_type_names_and_regexps
:type_and_nested_types => types_and_type_names_and_regexps
:name_and_nested_types => types_and_type_names_and_regexps
:types_and_nested => types_and_type_names_and_regexps
:names_and_nested => types_and_type_names_and_regexps
:type_and_nested => types_and_type_names_and_regexps
:name_and_nested => types_and_type_names_and_regexps
You can also append the suffix “_of” on any of the “*_types” keys.
Note: This option will also match Class
, Module
,
<i>etc.</>, so use with caution!
To get both descendents and ancestors, use both options with the same type specification.
Exclude the specified type(s) from the list of matched types. Note: These excluded types won’t appear in the Aquarium::Finders::FinderResult#not_matched.
:exclude_type => types_and_type_names_and_regexps
:exclude_types => types_and_type_names_and_regexps
:exclude_name => types_and_type_names_and_regexps
:exclude_names => types_and_type_names_and_regexps
:exclude_types_and_descendents =>
types_and_type_names_and_regexps
:exclude_names_and_descendents =>
types_and_type_names_and_regexps
:exclude_type_and_descendents =>
types_and_type_names_and_regexps
:exclude_name_and_descendents =>
types_and_type_names_and_regexps
:exclude_types_and_ancestors =>
types_and_type_names_and_regexps
:exclude_names_and_ancestors =>
types_and_type_names_and_regexps
:exclude_type_and_ancestors =>
types_and_type_names_and_regexps
:exclude_name_and_ancestors =>
types_and_type_names_and_regexps
:exclude_types_and_nested_types =>
types_and_type_names_and_regexps
:exclude_names_and_nested_types =>
types_and_type_names_and_regexps
:exclude_type_and_nested_types =>
types_and_type_names_and_regexps
:exclude_name_and_nested_types =>
types_and_type_names_and_regexps
:exclude_types_and_nested =>
types_and_type_names_and_regexps
:exclude_names_and_nested =>
types_and_type_names_and_regexps
:exclude_type_and_nested =>
types_and_type_names_and_regexps
:exclude_name_and_nested =>
types_and_type_names_and_regexps
You can also append the suffix “_of” on any of the “*_descendents”, “*_ancestors”, and “*_types” keys.
Because of the special sigificance of the module (“namespace”) separator “::”, special rules for the regular expressions apply. Normally, you can just use the “*_and_nested_types” or “*_and_nested” to match enclosed types, but if you want to be selective, note the following. First, assume that “subexp” is a “sub regular expression” that results if you split on the separator “::”.
Allow partial matches, i.e., as if you wrote
/^.*#{regexp}.*$/.
It behaves as /^.*#{subexp}::.../
, meaning that the end of
“subexp” must be followed by “::”.
It behaves as /...::#{subexp}$/
, meaning that the beginning of
“subexp” must immediately follow a “::”.
It behaves as /...::#{subexp}::.../
, meaning that the subexp
must match the whole name between the “::” exactly.
Note: a common idiom in aspects is to include descendents of a type, but not the type itself. You can do as in the following example:
<tt>... :type_and_descendents => "Foo", :exclude_type => "Foo"
# File lib/aquarium/finders/type_finder.rb, line 159 def find options = {} init_specification options, CANONICAL_OPTIONS result = do_find_types unset_specification result end