Class: Basecampeverest::Convert
- Inherits:
-
Object
- Object
- Basecampeverest::Convert
- Defined in:
- lib/basecampeverest/convert.rb
Instance Method Summary collapse
- #convert_to_ostruct_recursive(obj, options) ⇒ Object
-
#to_ostruct_recursive(options) ⇒ Basecampeverest::Project
convert an array into a nested OpenStruct.
Instance Method Details
#convert_to_ostruct_recursive(obj, options) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/basecampeverest/convert.rb', line 14 def convert_to_ostruct_recursive(obj, ) result = obj if result.is_a? Hash result = result.dup.with_sym_keys result.each do |key, val| result[key] = convert_to_ostruct_recursive(val, ) unless [:exclude].try(:include?, key) end result = OpenStruct.new result elsif result.is_a? Array result = result.map { |r| convert_to_ostruct_recursive(r, ) } end return result end |
#to_ostruct_recursive(options) ⇒ Basecampeverest::Project
convert an array into a nested OpenStruct
10 11 12 |
# File 'lib/basecampeverest/convert.rb', line 10 def to_ostruct_recursive() convert_to_ostruct_recursive(self, ) end |