Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Rack::Cache.new yields itself to the block instead of instance_eval

  • Loading branch information...
commit 54133fcf41f61ce2d0f9cf38972889b45969c68e 1 parent 11765d8
@rtomayko rtomayko authored
Showing with 9 additions and 8 deletions.
  1. +3 −2 lib/rack/cache/context.rb
  2. +6 −6 test/cache_test.rb
View
5 lib/rack/cache/context.rb
@@ -15,11 +15,12 @@ class Context
# The Rack application object immediately downstream.
attr_reader :backend
- def initialize(backend, options={}, &block)
+ def initialize(backend, options={})
@backend = backend
@trace = []
+
initialize_options options
- instance_eval(&block) if block_given?
+ yield self if block_given?
@private_header_keys =
private_headers.map { |name| "HTTP_#{name.upcase.tr('-', '_')}" }
View
12 test/cache_test.rb
@@ -25,14 +25,14 @@ def dumb_app(env)
end
it 'takes a block; executes it during initialization' do
- state, block_scope = 'not invoked', nil
- object =
- Rack::Cache.new @app do
- block_scope = self
+ state, object = 'not invoked', nil
+ instance =
+ Rack::Cache.new @app do |cache|
+ object = cache
state = 'invoked'
- should.respond_to :set
+ cache.should.respond_to :set
end
state.should.equal 'invoked'
- object.should.be block_scope
+ object.should.be instance
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.