Class: MongoRequestLogger::Adapters::Base
- Inherits:
-
Object
- Object
- MongoRequestLogger::Adapters::Base
- Defined in:
- lib/mongo_request_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
- #reconnect ⇒ Object
- #reset_collection ⇒ Object
Instance Attribute Details
#authenticated ⇒ Object (readonly)
Returns the value of attribute authenticated.
7 8 9 |
# File 'lib/mongo_request_logger/adapters/base.rb', line 7 def authenticated @authenticated end |
#collection ⇒ Object (readonly)
Returns the value of attribute collection.
7 8 9 |
# File 'lib/mongo_request_logger/adapters/base.rb', line 7 def collection @collection end |
#configuration ⇒ Object (readonly)
Returns the value of attribute configuration.
7 8 9 |
# File 'lib/mongo_request_logger/adapters/base.rb', line 7 def configuration @configuration end |
#connection ⇒ Object (readonly)
Returns the value of attribute connection.
7 8 9 |
# File 'lib/mongo_request_logger/adapters/base.rb', line 7 def connection @connection end |
#connection_type ⇒ Object (readonly)
Returns the value of attribute connection_type.
7 8 9 |
# File 'lib/mongo_request_logger/adapters/base.rb', line 7 def connection_type @connection_type end |
Instance Method Details
#authenticated? ⇒ Boolean
13 14 15 |
# File 'lib/mongo_request_logger/adapters/base.rb', line 13 def authenticated? @authenticated end |
#check_for_collection ⇒ Object
17 18 19 20 21 |
# File 'lib/mongo_request_logger/adapters/base.rb', line 17 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
9 10 11 |
# File 'lib/mongo_request_logger/adapters/base.rb', line 9 def collection_name @configuration['collection'] end |
#collection_stats_hash(stats) ⇒ Object
34 35 36 37 38 39 40 41 42 43 |
# File 'lib/mongo_request_logger/adapters/base.rb', line 34 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
45 46 47 |
# File 'lib/mongo_request_logger/adapters/base.rb', line 45 def create_collection raise "Not implemented" end |
#reconnect ⇒ Object
30 31 32 |
# File 'lib/mongo_request_logger/adapters/base.rb', line 30 def reconnect end |
#reset_collection ⇒ Object
23 24 25 26 27 28 |
# File 'lib/mongo_request_logger/adapters/base.rb', line 23 def reset_collection if @connection && @collection @collection.drop create_collection end end |