You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

15 lines
235B

  1. require 'ostruct'
  2. class OpenStruct
  3. def self.deep(value)
  4. case value
  5. when Hash
  6. self.new value.collect { |k, v| [k, self.deep(v)] }.to_h
  7. when Enumerable
  8. value.collect { |v| self.deep v }
  9. else
  10. value
  11. end
  12. end
  13. end