Skip to content

Commit

Permalink
add Hash#except to core_ext so we don't rely on activesupport being p…
Browse files Browse the repository at this point in the history
…resent
  • Loading branch information
Sven Fuchs committed Jan 23, 2010
1 parent 04edc27 commit 17e923d
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/i18n/backend/base.rb
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
Expand Down
8 changes: 8 additions & 0 deletions lib/i18n/core_ext/hash/except.rb
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)
8 changes: 8 additions & 0 deletions lib/i18n/core_ext/hash/slice.rb
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)

0 comments on commit 17e923d

Please sign in to comment.