aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/core_ext/module
diff options
context:
space:
mode:
authorDaniel Schierbeck <dasch@zendesk.com>2012-04-12 14:55:30 +0200
committerDaniel Schierbeck <dasch@zendesk.com>2012-04-12 14:55:30 +0200
commit5fb6bd8b22327b00061602b64af8c08886abc581 (patch)
tree256e8b32c4e29468c15dd0e654f46250d53323f5 /activesupport/lib/active_support/core_ext/module
parent402a119ddb886cc60b6e6c120aff964a6d4780af (diff)
downloadrails-5fb6bd8b22327b00061602b64af8c08886abc581.tar.gz
rails-5fb6bd8b22327b00061602b64af8c08886abc581.tar.bz2
rails-5fb6bd8b22327b00061602b64af8c08886abc581.zip
Remove Module#delegate!
Diffstat (limited to 'activesupport/lib/active_support/core_ext/module')
-rw-r--r--activesupport/lib/active_support/core_ext/module/delegation.rb52
1 files changed, 0 insertions, 52 deletions
diff --git a/activesupport/lib/active_support/core_ext/module/delegation.rb b/activesupport/lib/active_support/core_ext/module/delegation.rb
index b927059c6b..ee8adae1cb 100644
--- a/activesupport/lib/active_support/core_ext/module/delegation.rb
+++ b/activesupport/lib/active_support/core_ext/module/delegation.rb
@@ -156,56 +156,4 @@ class Module
end
end
end
-
- def delegate!(*methods)
- ActiveSupport::Deprecation.warn('Delegating to non-public methods is deprecated.', caller)
-
- options = methods.pop
- unless options.is_a?(Hash) && to = options[:to]
- raise ArgumentError, "Delegation needs a target. Supply an options hash with a :to key as the last argument (e.g. delegate :hello, :to => :greeter)."
- end
- prefix, to, allow_nil = options[:prefix], options[:to], options[:allow_nil]
-
- if prefix == true && to.to_s =~ /^[^a-z_]/
- raise ArgumentError, "Can only automatically set the delegation prefix when delegating to a method."
- end
-
- method_prefix =
- if prefix
- "#{prefix == true ? to : prefix}_"
- else
- ''
- end
-
- file, line = caller.first.split(':', 2)
- line = line.to_i
-
- methods.each do |method|
- method = method.to_s
-
- if allow_nil
- module_eval(<<-EOS, file, line - 2)
- def #{method_prefix}#{method}(*args, &block) # def customer_name(*args, &block)
- if #{to} || #{to}.respond_to?(:#{method}) # if client || client.respond_to?(:name)
- #{to}.__send__(:#{method}, *args, &block) # client.__send__(:name, *args, &block)
- end # end
- end # end
- EOS
- else
- exception = %(raise "#{self}##{method_prefix}#{method} delegated to #{to}.#{method}, but #{to} is nil: \#{self.inspect}")
-
- module_eval(<<-EOS, file, line - 1)
- def #{method_prefix}#{method}(*args, &block) # def customer_name(*args, &block)
- #{to}.__send__(:#{method}, *args, &block) # client.__send__(:name, *args, &block)
- rescue NoMethodError # rescue NoMethodError
- if #{to}.nil? # if client.nil?
- #{exception} # # add helpful message to the exception
- else # else
- raise # raise
- end # end
- end # end
- EOS
- end
- end
- end
end