module Roda::RodaPlugins::ClassMatchers::ClassMethods

  1. lib/roda/plugins/class_matchers.rb

Methods

Public Instance

  1. class_matcher
  2. freeze

Public Instance methods

class_matcher(klass, matcher, &block)

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

If providing a regexp, the block given will be called with all regexp captures. If providing a registered class or symbol, the block will be called with the captures returned by the block for the registered class or symbol, or the regexp captures if no block was registered with the class or symbol. In either case, if a block is given, it should return an array with the captures to yield to the match block.

[show source]
    # File lib/roda/plugins/class_matchers.rb
 95 def class_matcher(klass, matcher, &block)
 96   _symbol_class_matcher(Class, klass, matcher, block) do |meth, (_, regexp, convert_meth)|
 97     if regexp
 98       define_method(meth){consume(regexp, convert_meth)}
 99     else
100       define_method(meth){_consume_segment(convert_meth)}
101     end
102   end
103 end
freeze()

Freeze the class_matchers hash when freezing the app.

[show source]
    # File lib/roda/plugins/class_matchers.rb
106 def freeze
107   opts[:class_matchers].freeze
108   super
109 end