Module: Brandish::Processor::Block
- Included in:
- Brandish::Processors::All::Comment, Brandish::Processors::All::Embed, Brandish::Processors::All::If, Brandish::Processors::All::Literal, Brandish::Processors::Common::Asset, Brandish::Processors::Common::Group, Brandish::Processors::HTML::Group
- Defined in:
- lib/brandish/processor/block.rb
Overview
A block processor. This is designed to act over a base to modify one specific block. The block name itself is specified on the class, and the class provides logic to only modify block nodes with the same name.
Class Method Summary collapse
-
.included(base) ⇒ void
private
Ruby hook.
Instance Method Summary collapse
-
#perform ⇒ ::Object
abstract
Performs the command adjustment.
-
#process_block(node) ⇒ ::Object
Processes the block.
Class Method Details
.included(base) ⇒ void
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.
This method returns an undefined value.
Ruby hook.
15 16 17 18 |
# File 'lib/brandish/processor/block.rb', line 15 def self.included(base) base.include Processor::NameFilter base.include Processor::PairFilter end |
Instance Method Details
#perform ⇒ ::Object
This method is abstract.
Performs the command adjustment. This must be subclassed and overwritten.
42 43 44 |
# File 'lib/brandish/processor/block.rb', line 42 def perform fail NotImplementedError, "Please implement #{self.class}#perform" end |
#process_block(node) ⇒ ::Object
Processes the block. If the node's name doesn't match the name for this class, it passes it on up to Brandish::Processor::Base#process_block; otherwise, it passes it over to #perform.
26 27 28 29 30 31 32 33 34 35 |
# File 'lib/brandish/processor/block.rb', line 26 def process_block(node) return super unless allowed_names.include?(node.name) @node = node @name = node.name @pairs = node.pairs @body = node.body assert_valid_pairs perform end |