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: InstanceMethods

Class Method Summary collapse

Class Method Details

.configure(app, max = nil) ⇒ Object



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

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