Class: MongodbLogger::Adapers::Base
- Inherits:
-
Object
- Object
- MongodbLogger::Adapers::Base
- Defined in:
- lib/mongodb_logger/adapters/base.rb
Instance Attribute Summary collapse
-
#authenticated ⇒ Object
readonly
Returns the value of attribute authenticated.
-
#collection ⇒ Object
readonly
Returns the value of attribute collection.
-
#configuration ⇒ Object
readonly
Returns the value of attribute configuration.
-
#connection ⇒ Object
readonly
Returns the value of attribute connection.
-
#connection_type ⇒ Object
readonly
Returns the value of attribute connection_type.
Instance Method Summary collapse
- #authenticated? ⇒ Boolean
- #check_for_collection ⇒ Object
- #collection_name ⇒ Object
- #collection_stats_hash(stats) ⇒ Object
- #create_collection ⇒ Object
- #rename_collection_command(admin_session, to, drop_target = false) ⇒ Object
- #reset_collection ⇒ Object
Instance Attribute Details
#authenticated ⇒ Object (readonly)
Returns the value of attribute authenticated.
5 6 7 |
# File 'lib/mongodb_logger/adapters/base.rb', line 5 def authenticated @authenticated end |
#collection ⇒ Object (readonly)
Returns the value of attribute collection.
5 6 7 |
# File 'lib/mongodb_logger/adapters/base.rb', line 5 def collection @collection end |
#configuration ⇒ Object (readonly)
Returns the value of attribute configuration.
5 6 7 |
# File 'lib/mongodb_logger/adapters/base.rb', line 5 def configuration @configuration end |
#connection ⇒ Object (readonly)
Returns the value of attribute connection.
5 6 7 |
# File 'lib/mongodb_logger/adapters/base.rb', line 5 def connection @connection end |
#connection_type ⇒ Object (readonly)
Returns the value of attribute connection_type.
5 6 7 |
# File 'lib/mongodb_logger/adapters/base.rb', line 5 def connection_type @connection_type end |
Instance Method Details
#authenticated? ⇒ Boolean
11 12 13 |
# File 'lib/mongodb_logger/adapters/base.rb', line 11 def authenticated? @authenticated end |
#check_for_collection ⇒ Object
15 16 17 18 19 |
# 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 ⇒ Object
7 8 9 |
# File 'lib/mongodb_logger/adapters/base.rb', line 7 def collection_name @configuration[:collection] end |
#collection_stats_hash(stats) ⇒ Object
32 33 34 35 36 37 38 39 40 41 |
# 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 ⇒ Object
43 44 45 |
# 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) ⇒ Object
21 22 23 |
# 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 ⇒ Object
25 26 27 28 29 30 |
# File 'lib/mongodb_logger/adapters/base.rb', line 25 def reset_collection if @connection && @collection @collection.drop create_collection end end |