Sha256: 529a607da84151326a95d8a27550c5fbe26172e0625f93d0a5d2772afe5b5914

Contents?: true

Size: 612 Bytes

Versions: 6

Compression:

Stored size: 612 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.reduce Hash.new, :merge
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
mongodb-graphite-agent-0.1.4 lib/mongodb/graphite/agent/utils.rb
mongodb-graphite-agent-0.1.3 lib/mongodb/graphite/agent/utils.rb
mongodb-graphite-agent-0.1.2 lib/mongodb/graphite/agent/utils.rb
mongodb-graphite-agent-0.0.8 lib/mongodb/graphite/agent/utils.rb
mongodb-graphite-agent-0.0.6 lib/mongodb/graphite/agent/utils.rb
mongodb-graphite-agent-0.0.5 lib/mongodb/graphite/agent/utils.rb