Sha256: 0616cfb810afea6523424f88f102827c4f40d2284219890d9d8a93cced9d7b1a

Contents?: true

Size: 375 Bytes

Versions: 3

Compression:

Stored size: 375 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 as_json
        Hash[to_h.map { |item| [StringUtil.camelize(item[0]), item[1]] }]
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
moleculer-0.2.0 lib/moleculer/support/open_struct.rb
moleculer-0.1.1 lib/moleculer/support/open_struct.rb
moleculer-0.1.0 lib/moleculer/support/open_struct.rb