rails_middleware_delegator 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f4a16552a8dbcd8a60786b81efbb33c97c0a4829
4
- data.tar.gz: 7109b4d2c327a2c1e4c727434c8f2bc38c2bbc26
3
+ metadata.gz: 6c6a31a0512e404e6a860dc168bb5e93f204b5d0
4
+ data.tar.gz: dbd58446d0e5cae0c32fd25f61afce3e89f9dfa7
5
5
  SHA512:
6
- metadata.gz: 7d55b86b2ff7b76d64a250a2eb942de1d79cea8d15e24d755ffb403eb7b6038587320d502d747a6de3518bdaf43ac6b0b03ba39b4b4ea887ca0a2d89eab581b7
7
- data.tar.gz: e100aa024e62a68da53c90cb9cd54d54d4e23cf71a0ee9f992313861949e5d25c4ee5806fda6ca26ff01b5121998b81de600fe50754e9266f712599f4e6adc89
6
+ metadata.gz: d9b6ce821544fb0835f3ef0d151d74f2c2e65b76e9e2136076a5dbc2dd4bfa144ca606831bb5e369c7db9fcaec0b7144ccead13e9314f758012e58a8a7ff92cf
7
+ data.tar.gz: 889cfc53f78551ba22dd25a8cc8fd342e84175116666b428636fc1bc23c12a97ffa5650c6cf305c885f4707e8ce0ae62db28648eb2ab94a2ddc0c3254bb62f26
data/README.md CHANGED
@@ -1,41 +1,46 @@
1
- # RailsMiddlewareDelegator
1
+ RailsMiddlewareDelegator
2
+ ========================
2
3
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/rails_middleware_delegator`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+ When using Rails middleware, a common problem is that middleware loaded from `lib`
5
+ does not reload between requests. In order for changes to these middleware classes
6
+ to be reflected in a running server, the development server process must be
7
+ killed and restarted.
4
8
 
5
- TODO: Delete this and the text above, and describe your gem
9
+ If one were to drop a middleware class into a subdirectory of `app` and rely on
10
+ autoloading, however, changing any other autoloaded file and making a new
11
+ server request results in an error, `A copy of X has been removed from the module
12
+ tree bus is still active`. Upon starting the server, an instance of the class was
13
+ loaded into memory. At the end of the request, the class was unloaded. On the
14
+ second request upon running through the middleware stack, Rails detected that it
15
+ was executing through an instance of an unloaded class. Boom!
6
16
 
7
- ## Installation
17
+ This gem provides a delegator class that can wrap the unloadable middleware. Instead
18
+ of registering the middleware itself, you can use an instance of the delegator,
19
+ which being a gem managed by bundler will not be unloaded between requests.
8
20
 
9
- Add this line to your application's Gemfile:
21
+ In environments where `cache_classes` is `true`, the delegator steps out of the way
22
+ and adds the delegated middleware directly onto the stack. When `false`, it holds
23
+ onto any passed configuration and instantiates a new middleware instance for each
24
+ request.
10
25
 
11
- ```ruby
12
- gem 'rails_middleware_delegator'
13
- ```
14
-
15
- And then execute:
16
-
17
- $ bundle
18
-
19
- Or install it yourself as:
20
-
21
- $ gem install rails_middleware_delegator
22
26
 
23
27
  ## Usage
24
28
 
25
- TODO: Write usage instructions here
26
-
27
- ## Development
28
-
29
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
29
+ ```
30
+ Rails.application.config.middleware.use RailsMiddlewareDelegator.new('MyMiddleware')
31
+ ```
30
32
 
31
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
33
 
33
34
  ## Contributing
34
35
 
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/rails_middleware_delegator. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
36
+ Bug reports and pull requests are welcome on GitHub at
37
+ https://github.com/[USERNAME]/rails_middleware_delegator. This project is intended
38
+ to be a safe, welcoming space for collaboration, and contributors are expected to
39
+ adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
36
40
 
37
41
 
38
42
  ## License
39
43
 
40
- The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
44
+ The gem is available as open source under the terms of the
45
+ [MIT License](http://opensource.org/licenses/MIT).
41
46
 
@@ -32,7 +32,7 @@ class RailsMiddlewareDelegator
32
32
 
33
33
  def new(*args)
34
34
  @initialization_args = args
35
- Rails.env.development? ? self : klass.constantize.new(*args)
35
+ Rails.application.config.cache_classes ? klass.constantize.new(*args) : self
36
36
  end
37
37
 
38
38
  def call(*args)
@@ -1,3 +1,3 @@
1
1
  class RailsMiddlewareDelegator
2
- VERSION = '0.1.0'.freeze
2
+ VERSION = '0.1.1'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_middleware_delegator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Saxby