Module: Brandish::Processor::PairFilter::InstanceMethods

Defined in:
lib/brandish/processor/pair_filter.rb

Overview

The instance methods on the including class.

Instance Method Summary collapse

Instance Method Details

#allowed_pairs::Set<::String>

A list of all of the ancestors' pairs. This includes the current classes' pairs. This allows allowed pair inheritance.

Returns:

  • (::Set<::String>)


69
70
71
# File 'lib/brandish/processor/pair_filter.rb', line 69

def allowed_pairs
  self.class.ancestor_allowed_pairs
end

#assert_valid_pairsvoid

This method returns an undefined value.

Asserts that the pairs given are all allowed. This uses the @pairs and @node instance variables.

Raises:

  • (PairError)

    If an invalid pair was given.



78
79
80
81
82
83
84
# File 'lib/brandish/processor/pair_filter.rb', line 78

def assert_valid_pairs
  return if allowed_pairs.include?(PairFilter::ALL)
  excessive = @pairs.keys - allowed_pairs
  return unless excessive.any?
  fail PairError.new("Unexpected pairs found " \
    "(#{excessive.map(&:inspect).join(', ')})", @node.location)
end