Permalink
Browse files

Use active_support/concern for module inclusion helpers

  • Loading branch information...
1 parent 91af8ec commit 5abaee5ae3d74d3bd4f7b058536565790b6011f3 Andy Delcambre committed Apr 3, 2010
Showing with 24 additions and 15 deletions.
  1. +3 −0 Rakefile
  2. +14 −14 lib/rails_action_args/abstract_controller.rb
  3. +7 −1 rails-action-args.gemspec
View
@@ -12,6 +12,9 @@ begin
gem.homepage = "http://github.com/adelcambre/rails-action-args"
gem.authors = ["Andy Delcambre"]
+ gem.add_dependency "actionpack"
+ gem.add_dependency "activesupport"
+
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
end
rescue LoadError
@@ -1,26 +1,26 @@
+require 'abstract_controller'
+require 'active_support/concern'
+
# Hook up the BadRequest exception to return 400 Bad Request
class AbstractController::BadRequest < StandardError; end
ActionDispatch::ShowExceptions.rescue_responses["AbstractController::BadRequest"] = :bad_request
module ActionArgs
+ extend ActiveSupport::Concern
- def self.included(base)
- base.class_eval do
- class << self
- def action_arguments(action)
- @action_arguments ||= {}
- return @action_arguments[action] if @action_arguments[action]
+ module ClassMethods
+ def action_arguments(action)
+ @action_arguments ||= {}
+ return @action_arguments[action] if @action_arguments[action]
- arguments = instance_method(action).get_args.first || []
+ arguments = instance_method(action).get_args.first || []
- defaults = arguments.map do |arg|
- if arg.size == 2
- arg.first
- end
- end.compact
- @action_arguments[action] = [arguments, defaults]
+ defaults = arguments.map do |arg|
+ if arg.size == 2
+ arg.first
end
- end
+ end.compact
+ @action_arguments[action] = [arguments, defaults]
end
end
@@ -9,7 +9,7 @@ Gem::Specification.new do |s|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["Andy Delcambre"]
- s.date = %q{2010-04-02}
+ s.date = %q{2010-04-03}
s.description = %q{Rails Action Args allows you to accept the parameters to you action as arguments to the action method.}
s.email = %q{adelcambre@engineyard.com}
s.extra_rdoc_files = [
@@ -51,9 +51,15 @@ Gem::Specification.new do |s|
s.specification_version = 3
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
+ s.add_runtime_dependency(%q<actionpack>, [">= 0"])
+ s.add_runtime_dependency(%q<activesupport>, [">= 0"])
else
+ s.add_dependency(%q<actionpack>, [">= 0"])
+ s.add_dependency(%q<activesupport>, [">= 0"])
end
else
+ s.add_dependency(%q<actionpack>, [">= 0"])
+ s.add_dependency(%q<activesupport>, [">= 0"])
end
end

0 comments on commit 5abaee5

Please sign in to comment.