module Roda::RodaPlugins::IntegerMatcherMax

  1. lib/roda/plugins/Integer_matcher_max.rb

The Integer_matcher_max plugin sets the maximum integer value value that the Integer class matcher will match by default. By default, loading this plugin sets the maximum value to 2**63-1, the largest signed 64-bit integer value:

plugin :Integer_matcher_max
route do |r|
  r.is Integer do
    # Matches /9223372036854775807
    # Does not match /9223372036854775808
  end
end

To specify a different maximum value, you can pass a different maximum value when loading the plugin:

plugin :Integer_matcher_max, 2**64-1

Methods

Public Class

  1. configure

Public Class methods

configure(app, max=nil)
[show source]
   # File lib/roda/plugins/Integer_matcher_max.rb
24 def self.configure(app, max=nil)
25   if max
26     app.class_eval do
27       meth = :_max_value_convert_class_Integer
28       define_method(meth){max}
29       alias_method meth, meth
30       private meth
31     end
32   end
33 end