class Rack::When::Builder

Public Class Methods

new(*args) click to toggle source
# File lib/rack/when/builder.rb, line 5
def initialize *args
  *@envs, @block = args
end

Public Instance Methods

has_matching_env?() click to toggle source
# File lib/rack/when/builder.rb, line 13
def has_matching_env?
  @envs.any? { |env| (ENV['RACK_ENV'] || ENV['RAILS_ENV'] || 'development') =~ /^#{env.to_s.downcase}/ }
end
mount() click to toggle source
# File lib/rack/when/builder.rb, line 9
def mount
  @block.call if has_matching_env?
end