Sha256: 1e5750d9c657dc03bebecbb3cf1294d3ee0aeff1d23678c7371ea2f640935e7a

Contents?: true

Size: 349 Bytes

Versions: 3

Compression:

Stored size: 349 Bytes

Contents

module Rack
  module When
    class Builder

      def initialize *args
        *@envs, @block = args
      end

      def mount
        @block.call if has_matching_env?
      end

      def has_matching_env?
        @envs.any? { |env| (ENV['RACK_ENV'] || ENV['RAILS_ENV'] || 'development') =~ /^#{env.to_s.downcase}/ }
      end

    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rack-when-1.0.0 lib/rack/when/builder.rb
rack-when-0.0.4 lib/rack/when/builder.rb
rack-when-0.0.3 lib/rack/when/builder.rb