class MongodbLogger::Adapers::Base
Attributes
authenticated[R]
collection[R]
configuration[R]
connection[R]
connection_type[R]
Public Instance Methods
authenticated?()
click to toggle source
# File lib/mongodb_logger/adapters/base.rb, line 11 def authenticated? @authenticated end
check_for_collection()
click to toggle source
# File lib/mongodb_logger/adapters/base.rb, line 15 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
collection_name()
click to toggle source
# File lib/mongodb_logger/adapters/base.rb, line 7 def collection_name @configuration[:collection] end
collection_stats_hash(stats)
click to toggle source
# File lib/mongodb_logger/adapters/base.rb, line 32 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
create_collection()
click to toggle source
# File lib/mongodb_logger/adapters/base.rb, line 43 def create_collection raise "Not implemented" end
rename_collection_command(admin_session, to, drop_target = false)
click to toggle source
# File lib/mongodb_logger/adapters/base.rb, line 21 def rename_collection_command(admin_session, to, drop_target = false) admin_session.command(renameCollection: "#{@configuration[:database]}.#{collection_name}", to: "#{@configuration[:database]}.#{to}", dropTarget: drop_target) end
reset_collection()
click to toggle source
# File lib/mongodb_logger/adapters/base.rb, line 25 def reset_collection if @connection && @collection @collection.drop create_collection end end