Module: Brandish::Processor::PairFilter::ClassMethods
- Defined in:
- lib/brandish/processor/pair_filter.rb
Overview
The class methods that are implemented on the including module. This is extended onto the class.
Instance Method Summary collapse
-
#allowed_pairs ⇒ ::Set<::String>
A set of allowed pairs that can be used with the command or block element.
-
#ancestor_allowed_pairs ⇒ ::Set<::String>
A list of all of the ancestors' pairs.
-
#pairs(*pairs) ⇒ Object
(also: #pair)
Retrives or sets the pairs for the class.
-
#unrestricted_pairs! ⇒ void
(also: #unrestricted_pairs)
Adds ALL to the pair list, allowing all pairs to be used with the command or block.
Instance Method Details
#allowed_pairs ⇒ ::Set<::String>
A set of allowed pairs that can be used with the command or block element.
23 24 25 |
# File 'lib/brandish/processor/pair_filter.rb', line 23 def allowed_pairs @allowed_pairs ||= Set.new end |
#ancestor_allowed_pairs ⇒ ::Set<::String>
A list of all of the ancestors' pairs. This includes the current classes' pairs. This allows allowed pair inheritance.
31 32 33 34 35 36 |
# File 'lib/brandish/processor/pair_filter.rb', line 31 def ancestor_allowed_pairs ancestors .select { |a| a.respond_to?(:allowed_pairs) } .map(&:allowed_pairs) .inject(Set.new, :merge) end |
#pairs ⇒ ::Set<::String> #pairs(*pairs) ⇒ void Also known as: pair
Retrives or sets the pairs for the class.
50 51 52 53 |
# File 'lib/brandish/processor/pair_filter.rb', line 50 def pairs(*pairs) return allowed_pairs if pairs.none? allowed_pairs.merge(Array(pairs).flatten.map(&:to_s)) end |
#unrestricted_pairs! ⇒ void Also known as: unrestricted_pairs
This method returns an undefined value.
Adds ALL to the pair list, allowing all pairs to be used with the command or block.
60 61 62 |
# File 'lib/brandish/processor/pair_filter.rb', line 60 def unrestricted_pairs! pairs PairFilter::ALL end |