Module: Webhookr::OstructUtils
- Defined in:
- lib/webhookr/ostruct_utils.rb
Overview
Class Method Summary collapse
Class Method Details
.array_to_ostruct(array) ⇒ Object
24 25 26 |
# File 'lib/webhookr/ostruct_utils.rb', line 24 def self.array_to_ostruct(array) array.map { |r| to_ostruct(r) } end |
.hash_to_ostruct(hash) ⇒ Object
17 18 19 20 21 22 |
# File 'lib/webhookr/ostruct_utils.rb', line 17 def self.hash_to_ostruct(hash) hash.each do |key, val| hash[key] = to_ostruct(val) end OpenStruct.new(hash) end |
.to_ostruct(obj) ⇒ Object
6 7 8 9 10 11 12 13 14 15 |
# File 'lib/webhookr/ostruct_utils.rb', line 6 def self.to_ostruct(obj) case obj when Hash hash_to_ostruct(obj) when Array array_to_ostruct(obj) else obj end end |