Sha256: 5c0e7c6b90fac2e52fbf96ae16157a24a33efbf57fe5f499842696956c6a2c61

Contents?: true

Size: 559 Bytes

Versions: 2

Compression:

Stored size: 559 Bytes

Contents

module Mongodb
  module Graphite
    module Agent

      module Utils
        def self.merge_all
          self.inject({}) { |h1, h2|
            h1.merge! h2
          }
        end

        def self.json_descent(pre, json)
          json.map do |k, v|
            key = pre + [k]
            if v.is_a? BSON::OrderedHash
              json_descent(key, v)
            else
              {key.join('.') => v}
            end
          end
        end

        def self.to_hash(s)
          json_descent([], s).flatten
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
mongodb-graphite-agent-0.0.3 lib/mongodb/graphite/agent/utils.rb
mongodb-graphite-agent-0.0.2 lib/mongodb/graphite/agent/utils.rb