Module: Roda::RodaPlugins::IntegerMatcherMax

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

Overview

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

Defined Under Namespace

Modules: RequestMethods

Class Method Summary collapse

Class Method Details

.configure(app, max = nil) ⇒ Object



24
25
26
27
28
29
30
31
32
# File 'lib/roda/plugins/Integer_matcher_max.rb', line 24

def self.configure(app, max=nil)
  if max
    app::RodaRequest.class_eval do
      define_method(:_match_class_max_Integer){max}
      alias_method :_match_class_max_Integer, :_match_class_max_Integer
      private :_match_class_max_Integer
    end
  end
end