Module: Prawn::Accessibility::OptionInitializer Private

Defined in:
lib/prawn/accessibility/document.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.

Prepended onto Document#initialize to support the Prawn::Document.new(tagged: true, language: 'en-US') API. Tagging is opt-in: a document is tagged only when tagged: true is passed.

It strips the accessibility options before delegating to the original initializer (so no change to VALID_OPTIONS is needed), then wires up tagging and runs the user block — in that order, so the block runs with tagging already active.

Instance Method Summary collapse

Instance Method Details

#initialize(options = {}, &block) ⇒ Object

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.



153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
# File 'lib/prawn/accessibility/document.rb', line 153

def initialize(options = {}, &block)
  opts = options.dup
  tagged = opts.delete(:tagged)
  language = opts.delete(:language)

  # Delegate to the original initializer WITHOUT the block, so we can run
  # it ourselves after tagging is wired up.
  super(opts)

  install_accessibility(language) if tagged

  return unless block

  block.arity < 1 ? instance_eval(&block) : block[self]
end