Sha256: a1ac20d2ab436b741e6d71345cdb588cea49f7c549f1eb92a2ee6b929bc0cc3b

Contents?: true

Size: 316 Bytes

Versions: 2

Compression:

Stored size: 316 Bytes

Contents

require 'ostruct'

module RecursiveOpenStruct
  def build_open_struct(elem)
    case elem
      when Array
        elem.map { |x| build_open_struct x }
      when Hash
        elem = elem.inject({}) { |h, (k, v)| h[k] = build_open_struct(v); h }
        OpenStruct.new(elem)
      else
        elem
    end
  end
end

Version data entries

2 entries across 1 versions & 1 rubygems

Version Path
apl-library-0.0.90 lib/apl-library/recursive_open_struct.rb
apl-library-0.0.90 vendor/bundle/ruby/2.1.0/gems/apl-library-0.0.90/lib/apl-library/recursive_open_struct.rb