Class: Rack::When::Builder
- Inherits:
-
Object
- Object
- Rack::When::Builder
- Defined in:
- lib/rack/when/builder.rb
Instance Method Summary collapse
- #has_matching_env? ⇒ Boolean
-
#initialize(*args) ⇒ Builder
constructor
A new instance of Builder.
- #mount ⇒ Object
Constructor Details
#initialize(*args) ⇒ Builder
Returns a new instance of Builder.
5 6 7 |
# File 'lib/rack/when/builder.rb', line 5 def initialize *args *@envs, @block = args end |
Instance Method Details
#has_matching_env? ⇒ Boolean
13 14 15 |
# 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 ⇒ Object
9 10 11 |
# File 'lib/rack/when/builder.rb', line 9 def mount @block.call if has_matching_env? end |