module Roda::RodaPlugins::SymbolMatchers::ClassMethods

  1. lib/roda/plugins/symbol_matchers.rb

Methods

Public Instance

  1. freeze
  2. symbol_matcher

Public Instance methods

freeze()

Freeze the class_matchers hash when freezing the app.

[show source]
    # File lib/roda/plugins/symbol_matchers.rb
148 def freeze
149   symbol_matchers.freeze
150   super
151 end
symbol_matcher(s, matcher, opts=(no_positional_opts = true; OPTS), segment: opts[:segment], **kw, &block)

Set the matcher and block to use for the given class. The matcher can be a regexp, registered symbol matcher, or registered class matcher (if using the class_matchers plugin).

If providing a regexp, the block given will be called with all regexp captures. If providing a registered symbol or class, the block will be called with the captures returned by the block for the registered symbol or class, or the regexp captures if no block was registered with the symbol or class. In either case, if a block is given, it should return an object to yield to the match block, or an array to yield multiple arguments to the match block. If the block returns nil or false, it will be treated as not matching.

[show source]
    # File lib/roda/plugins/symbol_matchers.rb
137 def symbol_matcher(s, matcher, opts=(no_positional_opts = true; OPTS), segment: opts[:segment], **kw, &block)
138   RodaPlugins.check_keywords(__callee__, no_positional_opts, opts, kw)
139 
140   _symbol_class_matcher(Symbol, s, matcher, block, segment: segment) do |meth, array|
141     define_method(meth){array}
142   end
143 
144   nil
145 end