-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extracting 1.9.3 backported methods and fixes into a module.
This keeps the main class clean, and it makes it easy to know what was backported for 1.9.3. Closes #32
- Loading branch information
1 parent
c0e912a
commit 54cbd86
Showing
2 changed files
with
29 additions
and
22 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
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,27 @@ | ||
module RecursiveOpenStruct::Ruby19Backport | ||
# Apply fix if necessary: | ||
# https://github.com/ruby/ruby/commit/2d952c6d16ffe06a28bb1007e2cd1410c3db2d58 | ||
def initialize_copy(orig) | ||
super | ||
@table.each_key{|key| new_ostruct_member(key)} | ||
end | ||
|
||
def []=(name, value) | ||
modifiable[new_ostruct_member(name)] = value | ||
end | ||
|
||
def eql?(other) | ||
return false unless other.kind_of?(OpenStruct) | ||
@table.eql?(other.table) | ||
end | ||
|
||
def hash | ||
@table.hash | ||
end | ||
|
||
def each_pair | ||
return to_enum(:each_pair) { @table.size } unless block_given? | ||
@table.each_pair{|p| yield p} | ||
end | ||
end | ||
|