panmind-http_accept_language 1.1.0 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/VERSION +1 -1
  2. data/lib/http_accept_language.rb +10 -6
  3. metadata +3 -3
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.1.0
1
+ 1.1.1
@@ -80,10 +80,14 @@ module HttpAcceptLanguage
80
80
  languages.map {|l| l.to_s.sub(/-\w{2}/, '')}.uniq
81
81
  end
82
82
  end
83
- if defined?(ActionDispatch::Request)
84
- ActionDispatch::Request.send :include, HttpAcceptLanguage
85
- elsif defined?(ActionDispatch::AbstractRequest)
86
- ActionDispatch::AbstractRequest.send :include, HttpAcceptLanguage
87
- elsif defined?(ActionDispatch::CgiRequest)
88
- ActionDispatch::CgiRequest.send :include, HttpAcceptLanguage
83
+
84
+ # ActionDispatch is for Rails >= 3, Action Controller for Rails < 3
85
+ # Only the first class that matches gets the module included.
86
+ if defined? Rails
87
+ base = defined?(ActionDispatch) ? ActionDispatch : ActionController
88
+ [:Request, :AbstractRequest, :CgiRequest].each do |c|
89
+ next unless base.const_defined?(c)
90
+ base.const_get(c).instance_eval { include HttpAcceptLanguage }
91
+ break
92
+ end
89
93
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: panmind-http_accept_language
3
3
  version: !ruby/object:Gem::Version
4
- hash: 19
4
+ hash: 17
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
8
  - 1
9
- - 0
10
- version: 1.1.0
9
+ - 1
10
+ version: 1.1.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Iain Hecker