Sha256: 81641b8ef0221b25b914f97275771db56757eb22baf8b8489104e3a1ba60c4a3

Contents?: true

Size: 447 Bytes

Versions: 6

Compression:

Stored size: 447 Bytes

Contents

require 'json'

module Beryl
  module Deserializer
    extend self

    def deserialize(item, json = false)
      item = JSON.parse(item) unless json
      case item['class']
      when 'Hash'
        item['value'].each_with_object({}) do |(key, value), result|
          result[key.to_sym] = deserialize(value, true)
        end
      when 'Integer'
        item['value'].to_i
      when 'String'
        item['value']
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
beryl-0.2.5 lib/beryl/deserializer.rb
beryl-0.2.4 lib/beryl/deserializer.rb
beryl-0.2.3 lib/beryl/deserializer.rb
beryl-0.2.2 lib/beryl/deserializer.rb
beryl-0.2.1 lib/beryl/deserializer.rb
beryl-0.2.0 lib/beryl/deserializer.rb