-
-
Notifications
You must be signed in to change notification settings - Fork 408
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add Hash#except to core_ext so we don't rely on activesupport being p…
…resent
- Loading branch information
Sven Fuchs
committed
Jan 23, 2010
1 parent
04edc27
commit 17e923d
Showing
3 changed files
with
17 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
# encoding: utf-8 | ||
|
||
require 'yaml' | ||
require 'i18n/core_ext/hash/except' | ||
|
||
module I18n | ||
module Backend | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# from facets (http://facets.rubyforge.org) | ||
require 'i18n/core_ext/hash/slice' | ||
|
||
class Hash | ||
def except(*less_keys) | ||
slice(*keys - less_keys) | ||
end | ||
end unless Hash.method_defined?(:except) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# from facets (http://facets.rubyforge.org) | ||
class Hash | ||
def slice(*keep_keys) | ||
h = {} | ||
keep_keys.each { |key| h[key] = fetch(key) } | ||
h | ||
end | ||
end unless Hash.new.respond_to?(:slice) |