Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
merge locatables and attributes hashes in Element#initialize signature
- Loading branch information
Sven Fuchs
committed
Feb 14, 2010
1 parent
4a2ff20
commit 2ac792b
Showing
7 changed files
with
37 additions
and
11 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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
class Hash | ||
def except!(*keys) | ||
keys.map! { |key| convert_key(key) } if respond_to?(:convert_key) | ||
keys.each { |key| delete(key) } | ||
self | ||
end | ||
|
||
def except(*keys) | ||
dup.except!(*keys) | ||
end | ||
end unless Hash.method_defined?(:slice) |
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,14 @@ | ||
class Hash | ||
def slice!(*keys) | ||
omit = slice(*self.keys - keys) | ||
hash = slice(*keys) | ||
replace(hash) | ||
omit | ||
end | ||
|
||
def slice(*keys) | ||
hash = self.class.new | ||
keys.each { |k| hash[k] = self[k] if has_key?(k) } | ||
hash | ||
end | ||
end unless Hash.method_defined?(:slice) |
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
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
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
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
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