diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2012-11-13 11:11:11 -0800 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2012-11-13 11:11:11 -0800 |
commit | 8f6ce1a17ea1d73c3becc16ece79046e113daf8e (patch) | |
tree | 6c6f78f12accdc433c64680d5d6117967b76c5c2 /activesupport/lib | |
parent | 9ad8d670ec53eab64f0e0f0a248c2b11ebd79cc8 (diff) | |
download | rails-8f6ce1a17ea1d73c3becc16ece79046e113daf8e.tar.gz rails-8f6ce1a17ea1d73c3becc16ece79046e113daf8e.tar.bz2 rails-8f6ce1a17ea1d73c3becc16ece79046e113daf8e.zip |
backporting Struct#to_h from ruby 2.0
Diffstat (limited to 'activesupport/lib')
-rw-r--r-- | activesupport/lib/active_support/core_ext/struct.rb | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/activesupport/lib/active_support/core_ext/struct.rb b/activesupport/lib/active_support/core_ext/struct.rb new file mode 100644 index 0000000000..c2c30044f2 --- /dev/null +++ b/activesupport/lib/active_support/core_ext/struct.rb @@ -0,0 +1,6 @@ +# Backport of Struct#to_h from Ruby 2.0 +class Struct # :nodoc: + def to_h + Hash[members.zip(values)] + end +end unless Struct.instance_methods.include?(:to_h) |