Module: Roda::RodaPlugins::SymbolMatchers::ClassMethods

Defined in:
lib/roda/plugins/symbol_matchers.rb

Instance Method Summary collapse

Instance Method Details

#freezeObject

Freeze the class_matchers hash when freezing the app.



134
135
136
137
# File 'lib/roda/plugins/symbol_matchers.rb', line 134

def freeze
  opts[:symbol_matchers].freeze
  super
end

#symbol_matcher(s, matcher, &block) ⇒ Object

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 array with the captures to yield to the match block.



125
126
127
128
129
130
131
# File 'lib/roda/plugins/symbol_matchers.rb', line 125

def symbol_matcher(s, matcher, &block)
  _symbol_class_matcher(Symbol, s, matcher, block) do |meth, array|
    define_method(meth){array}
  end

  nil
end