Class: MongoDbUtils::Model::Config
- Inherits:
-
Object
- Object
- MongoDbUtils::Model::Config
- Defined in:
- lib/mongo-db-utils/models/config.rb
Instance Attribute Summary collapse
-
#backup_folder ⇒ Object
Returns the value of attribute backup_folder.
-
#buckets ⇒ Object
readonly
Returns the value of attribute buckets.
-
#dbs ⇒ Object
readonly
Returns the value of attribute dbs.
-
#writer ⇒ Object
writeonly
Sets the attribute writer.
Instance Method Summary collapse
-
#add_bucket(bucket) ⇒ Object
because we are serializing the config - the bucket may be nil at this point.
- #add_replica_set(uri, name) ⇒ Object
- #add_single_db(uri) ⇒ Object
- #already_contains(db) ⇒ Object
- #already_contains_bucket?(bucket) ⇒ Boolean
- #empty? ⇒ Boolean
- #flush ⇒ Object
- #has_buckets? ⇒ Boolean
-
#initialize ⇒ Config
constructor
A new instance of Config.
- #remove_db(db) ⇒ Object
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
10 11 12 13 |
# File 'lib/mongo-db-utils/models/config.rb', line 10 def initialize @dbs = [] @buckets = [] end |
Instance Attribute Details
#backup_folder ⇒ Object
Returns the value of attribute backup_folder.
8 9 10 |
# File 'lib/mongo-db-utils/models/config.rb', line 8 def backup_folder @backup_folder end |
#buckets ⇒ Object (readonly)
Returns the value of attribute buckets.
6 7 8 |
# File 'lib/mongo-db-utils/models/config.rb', line 6 def buckets @buckets end |
#dbs ⇒ Object (readonly)
Returns the value of attribute dbs.
6 7 8 |
# File 'lib/mongo-db-utils/models/config.rb', line 6 def dbs @dbs end |
#writer=(value) ⇒ Object (writeonly)
Sets the attribute writer
7 8 9 |
# File 'lib/mongo-db-utils/models/config.rb', line 7 def writer=(value) @writer = value end |
Instance Method Details
#add_bucket(bucket) ⇒ Object
because we are serializing the config - the bucket may be nil at this point
48 49 50 51 52 53 54 |
# File 'lib/mongo-db-utils/models/config.rb', line 48 def add_bucket(bucket) @buckets = [] if @buckets.nil? unless already_contains_bucket?(bucket) @buckets << bucket save end end |
#add_replica_set(uri, name) ⇒ Object
33 34 35 |
# File 'lib/mongo-db-utils/models/config.rb', line 33 def add_replica_set(uri, name) add_db ReplicaSetDb.new(uri,name) end |
#add_single_db(uri) ⇒ Object
38 39 40 |
# File 'lib/mongo-db-utils/models/config.rb', line 38 def add_single_db(uri) add_db Db.new(uri) end |
#already_contains(db) ⇒ Object
42 43 44 |
# File 'lib/mongo-db-utils/models/config.rb', line 42 def already_contains(db) !@dbs.find{|current| current.uri == db.uri }.nil? end |
#already_contains_bucket?(bucket) ⇒ Boolean
56 57 58 |
# File 'lib/mongo-db-utils/models/config.rb', line 56 def already_contains_bucket?(bucket) !@buckets.find{ |b| b.to_s == bucket.to_s}.nil? end |
#empty? ⇒ Boolean
15 16 17 |
# File 'lib/mongo-db-utils/models/config.rb', line 15 def empty? @dbs.nil? || @dbs.empty? end |
#flush ⇒ Object
23 24 25 26 |
# File 'lib/mongo-db-utils/models/config.rb', line 23 def flush @dbs = [] @writer.flush end |
#has_buckets? ⇒ Boolean
19 20 21 |
# File 'lib/mongo-db-utils/models/config.rb', line 19 def has_buckets? !@buckets.nil? && !@buckets.empty? end |
#remove_db(db) ⇒ Object
28 29 30 31 |
# File 'lib/mongo-db-utils/models/config.rb', line 28 def remove_db(db) @dbs = @dbs - [db] save end |