Skip to content

Commit

Permalink
use an anonymous module here
Browse files Browse the repository at this point in the history
  • Loading branch information
Sven Fuchs committed Oct 15, 2011
1 parent e02d87b commit c5d9e8c
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions lib/i18n.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ module I18n
RESERVED_KEYS = [:scope, :default, :separator, :resolve, :object, :fallback, :format, :cascade, :throw, :raise, :rescue_format]
RESERVED_KEYS_PATTERN = /%\{(#{RESERVED_KEYS.join("|")})\}/

module Base
extend Module.new {
# Gets I18n configuration object.
def config
Thread.current[:i18n_config] ||= I18n::Config.new
Expand Down Expand Up @@ -326,7 +326,5 @@ def default_exception_handler(exception, locale, key, options)
"(an instance of which is set to I18n.exception_handler by default)."
exception.is_a?(MissingTranslation) ? exception.message : raise(exception)
end
end

extend Base
}
end

1 comment on commit c5d9e8c

@mrjabba
Copy link

@mrjabba mrjabba commented on c5d9e8c Mar 5, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This may seem a dumb question, but what do we get with extend here? I understand Module.new a bit (anonymous module). And, I think I understand why the previous commit created a Base module. But, there was nothing wrong with config being defined as class methods, right? I'm just curious, because our team likes this config pattern. But, I wanted to be able to explain the use of extend for Module.new in this context. 😄 Great gem!

Please sign in to comment.