Sha256: 2dee4c0160faef762cb0b39ee7cff11744cb86f4e20087ef135d1d5dcf1ee513

Contents?: true

Size: 1.14 KB

Versions: 3

Compression:

Stored size: 1.14 KB

Contents

module MongodbLogger
  module Adapers
    class Base

      attr_reader :configuration, :connection, :connection_type, :collection, :authenticated

      def collection_name
        @configuration['collection']
      end

      def authenticated?
        @authenticated
      end

      def check_for_collection
        # setup the capped collection if it doesn't already exist
        create_collection unless @connection.collection_names.include?(@configuration['collection'])
        @collection = @connection[@configuration['collection']]
      end

      def reset_collection
        if @connection && @collection
          @collection.drop
          create_collection
        end
      end
      
      def collection_stats_hash(stats)
        {
          :is_capped => (stats["capped"] && ([1, true].include?(stats["capped"]))),
          :count => stats["count"].to_i,
          :size => stats["size"].to_f,
          :storageSize => stats["storageSize"].to_f,
          :db_name => @configuration["database"],
          :collection => collection_name
        }
      end

      def create_collection
        raise "Not implemented"
      end

    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
mongodb_logger-0.4.2 lib/mongodb_logger/adapters/base.rb
mongodb_logger-0.4.1 lib/mongodb_logger/adapters/base.rb
mongodb_logger-0.4.0 lib/mongodb_logger/adapters/base.rb