Module: Brandish::Processor::NameFilter::ClassMethods Private
- Defined in:
- lib/brandish/processor/name_filter.rb
Overview
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
The class methods that are implemented on the including module. This is extended onto the class.
Instance Method Summary collapse
-
#allowed_names ⇒ ::Set<::String>
private
A list of allowed names for the class.
-
#assumed_class_name ⇒ ::String
private
The name that is assumed from the class name.
-
#names(*names) ⇒ ::Set<::String>
(also: #names=)
private
If no names are given, it retrieves them using #allowed_names; otherwise, it merges the names into the allowed names set.
Instance Method Details
#allowed_names ⇒ ::Set<::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.
A list of allowed names for the class.
31 32 33 |
# File 'lib/brandish/processor/name_filter.rb', line 31 def allowed_names @names ||= name ? Set.new : Set[assumed_class_name] end |
#assumed_class_name ⇒ ::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.
The name that is assumed from the class name.
21 22 23 24 25 26 |
# File 'lib/brandish/processor/name_filter.rb', line 21 def assumed_class_name name .gsub(/\A(?:.+::)?(.*?)\z/, "\\1") .gsub(/(?<!\A)[A-Z]/) { |m| "-#{m}" } .downcase end |
#names(*names) ⇒ ::Set<::String> Also known as: names=
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.
If no names are given, it retrieves them using #allowed_names; otherwise, it merges the names into the allowed names set.
40 41 42 43 |
# File 'lib/brandish/processor/name_filter.rb', line 40 def names(*names) return allowed_names if names.none? allowed_names.merge(Array(names).flatten.map(&:to_s)) end |