Skip to content

Commit

Permalink
Revert const_missing bypass in favor of Duration constant lookup tweak
Browse files Browse the repository at this point in the history
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8412 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information
jeremy committed Dec 15, 2007
1 parent 3df9fb5 commit 6743504
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 6 deletions.
2 changes: 2 additions & 0 deletions activesupport/CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
*SVN*

* Ruby 1.9 compatibility. #1689, #10466, #10468 [Cheah Chu Yeow, Jeremy Kemper]

* TimeZone#to_s uses UTC rather than GMT. #1689 [Cheah Chu Yeow]

* Refactor of Hash#symbolize_keys! to use Hash#replace. Closes #10420 [ReinH]
Expand Down
5 changes: 0 additions & 5 deletions activesupport/lib/active_support/dependencies.rb
Original file line number Diff line number Diff line change
Expand Up @@ -461,11 +461,6 @@ def unloadable(const_desc = self)

class Class
def const_missing(const_name)
# Bypass entire lookup process if we can get the constant from Object.
# This is useful for Ruby 1.9 where Module#const_defined? looks up the
# ancestors in the chain for the constant.
return ::Object.const_get(const_name) if ::Object.const_defined?(const_name)

if [Object, Kernel].include?(self) || parent == self
super
else
Expand Down
2 changes: 1 addition & 1 deletion activesupport/lib/active_support/duration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def ago(time = ::Time.now)
alias :until :ago

def inspect #:nodoc:
consolidated = parts.inject(Hash.new(0)) { |h,part| h[part.first] += part.last; h }
consolidated = parts.inject(::Hash.new(0)) { |h,part| h[part.first] += part.last; h }
[:years, :months, :days, :minutes, :seconds].map do |length|
n = consolidated[length]
"#{n} #{n == 1 ? length.to_s.singularize : length.to_s}" if n.nonzero?
Expand Down

0 comments on commit 6743504

Please sign in to comment.