Sha256: 9055ff1345b2cc43650015c3456c7186aae143e41e7fe1d97f3aa998d1d246e0

Contents?: true

Size: 373 Bytes

Versions: 1

Compression:

Stored size: 373 Bytes

Contents

require "ostruct"

module Moleculer
  module Support
    ##
    # An OpenStruct that supports camelized serialization for JSON
    class OpenStruct < ::OpenStruct
      ##
      # @return [Hash] the object prepared for conversion to JSON for transmission
      def to_h
        Hash[super.map { |item| [StringUtil.camelize(item[0]), item[1]] }]
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
moleculer-0.3.0 lib/moleculer/support/open_struct.rb