Class: Rack::Noindex::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/rack/noindex/base.rb

Instance Method Summary collapse

Constructor Details

#initialize(app, condition) ⇒ Base

Returns a new instance of Base.



6
7
8
9
10
11
12
# File 'lib/rack/noindex/base.rb', line 6

def initialize(app, condition)
  if condition.nil?
    condition = lambda { |env| env['SERVER_NAME'] =~ /\.herokuapp\.com$/ }
  end
  @app = app
  @condition = condition
end

Instance Method Details

#call(env) ⇒ Object



14
15
16
17
18
# File 'lib/rack/noindex/base.rb', line 14

def call(env)
  status, headers, response = @app.call(env)
  headers['X-Robots-Tag'] = 'noindex' if @condition.call(env)
  [status, headers, response]
end