Skip to content

Loading…

Updating ActiveSupport patching to use #on_load; moved gem dependencies to gemspec. #31

Merged
merged 5 commits into from

4 participants

@kreeger

Per this Rails API Google Groups thread, I'm submitting a pull request to monkey-patch ActiveSupport instead of ActionController. This allows gems like has_scope to work with the rails-api project without any additional modification or patching.

In order to run the test suite successfully across several versions of Ruby (and to specify runtime vs development dependencies), I moved the gem dependencies from the Gemfile into the gemspec using the RubyGems API for doing so. If you'd rather I just push the ActiveSupport alteration by itself, let me know; I'd be more than happy to do so.

I didn't bump the version file, either; I figured I'd leave that up to the fearless upstream repository owners!

All tests pass under MRI versions 1.8.7-p358, 1.9.2-p290, 1.9.3-p125, and 2.0.0-preview1, and JRuby 1.7.

@josevalim josevalim merged commit 15d0679 into plataformatec:master
@josevalim
Plataformatec member

Very well done patch, thank you!

@steveklabnik

Oh man, this should help me in Draper, too. :metal:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 13 additions and 13 deletions.
  1. +0 −11 Gemfile
  2. +12 −1 has_scope.gemspec
  3. +1 −1 lib/has_scope.rb
View
11 Gemfile
@@ -1,14 +1,3 @@
source :rubygems
gemspec
-
-gem "actionpack", "~> 3.2.0"
-gem "activesupport", "~> 3.2.0"
-
-if RUBY_VERSION < "1.9"
- gem "ruby-debug"
-else
- gem "test-unit"
-end
-
-gem "mocha"
View
13 has_scope.gemspec
@@ -24,4 +24,15 @@ Gem::Specification.new do |s|
s.extra_rdoc_files = [
"README.md"
]
-end
+
+ s.add_runtime_dependency "actionpack", "~> 3.2.0"
+ s.add_runtime_dependency "activesupport", "~> 3.2.0"
+ s.add_development_dependency "mocha", "~> 0.12.0"
+ s.add_development_dependency "rake"
+ if RUBY_VERSION < "1.9"
+ s.add_development_dependency "rdoc"
+ s.add_development_dependency "ruby-debug"
+ else
+ s.add_development_dependency "test-unit"
+ end
+end
View
2 lib/has_scope.rb
@@ -181,7 +181,7 @@ def current_scopes
end
end
-ActionController::Base.instance_eval do
+ActiveSupport.on_load :action_controller do
include HasScope
helper_method :current_scopes
end
Something went wrong with that request. Please try again.