class Sablon::Processor::Document::FieldHandler
This class is used to setup field handlers to process different merge field expressions based on the expression text. The handles?
and build_statement
methods form the standard FieldHandler
API and can be implemented however they are needed to be as long as the call signature stays the same.
Public Class Methods
Used when registering processors. The pattern tells the handler what expression text to search for.
# File lib/sablon/processor/document/field_handlers.rb, line 12 def initialize(pattern) @pattern = pattern end
Public Instance Methods
Uses the provided arguments to construct a Statement
object. The constructor is an instance of the OperationConstruction
class, the field is the current merge field being evaluated and the options hash defines any other parameters passed in during OperationConstruction#consume
. Currently the only option passed is `:allow_insertion`.
# File lib/sablon/processor/document/field_handlers.rb, line 27 def build_statement(constructor, field, options = {}); end
Returns a non-nil value if the field expression matches the pattern
# File lib/sablon/processor/document/field_handlers.rb, line 17 def handles?(field) field.expression.match(@pattern) end