Class: Mongo::Lock::Configuration
- Inherits:
-
Object
- Object
- Mongo::Lock::Configuration
- Defined in:
- lib/mongo-lock/configuration.rb
Instance Attribute Summary collapse
-
#connections ⇒ Object
Returns the value of attribute connections.
-
#expires_after ⇒ Object
Returns the value of attribute expires_after.
-
#frequency ⇒ Object
Returns the value of attribute frequency.
-
#limit ⇒ Object
Returns the value of attribute limit.
-
#owner ⇒ Object
Returns the value of attribute owner.
-
#raise ⇒ Object
Returns the value of attribute raise.
-
#timeout_in ⇒ Object
Returns the value of attribute timeout_in.
Instance Method Summary collapse
- #collection(collection = :default) ⇒ Object
- #collection=(collection) ⇒ Object
- #collections ⇒ Object
- #collections=(collections) ⇒ Object
-
#initialize(defaults, options) {|_self| ... } ⇒ Configuration
constructor
A new instance of Configuration.
- #set_collections_keep_default(collections) ⇒ Object
- #to_hash ⇒ Object
Constructor Details
#initialize(defaults, options) {|_self| ... } ⇒ Configuration
Returns a new instance of Configuration.
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/mongo-lock/configuration.rb', line 13 def initialize defaults, , &block = defaults.merge() [:collections] ||= {} if [:collection] [:collections][:default] = [:collection] end .each_pair do |key,value| self.send(:"#{key}=",value) end yield self if block_given? end |
Instance Attribute Details
#connections ⇒ Object
Returns the value of attribute connections.
5 6 7 |
# File 'lib/mongo-lock/configuration.rb', line 5 def connections @connections end |
#expires_after ⇒ Object
Returns the value of attribute expires_after.
9 10 11 |
# File 'lib/mongo-lock/configuration.rb', line 9 def expires_after @expires_after end |
#frequency ⇒ Object
Returns the value of attribute frequency.
8 9 10 |
# File 'lib/mongo-lock/configuration.rb', line 8 def frequency @frequency end |
#limit ⇒ Object
Returns the value of attribute limit.
6 7 8 |
# File 'lib/mongo-lock/configuration.rb', line 6 def limit @limit end |
#owner ⇒ Object
Returns the value of attribute owner.
10 11 12 |
# File 'lib/mongo-lock/configuration.rb', line 10 def owner @owner end |
#raise ⇒ Object
Returns the value of attribute raise.
11 12 13 |
# File 'lib/mongo-lock/configuration.rb', line 11 def raise @raise end |
#timeout_in ⇒ Object
Returns the value of attribute timeout_in.
7 8 9 |
# File 'lib/mongo-lock/configuration.rb', line 7 def timeout_in @timeout_in end |
Instance Method Details
#collection(collection = :default) ⇒ Object
29 30 31 32 33 34 35 36 |
# File 'lib/mongo-lock/configuration.rb', line 29 def collection collection = :default collection = collection.to_sym if collection.is_a? String if collection.is_a? Symbol collections[collection] else collection end end |
#collection=(collection) ⇒ Object
25 26 27 |
# File 'lib/mongo-lock/configuration.rb', line 25 def collection= collection collections[:default] = collection end |
#collections ⇒ Object
47 48 49 |
# File 'lib/mongo-lock/configuration.rb', line 47 def collections @collections ||= {} end |
#collections=(collections) ⇒ Object
38 39 40 |
# File 'lib/mongo-lock/configuration.rb', line 38 def collections= collections @collections = collections end |
#set_collections_keep_default(collections) ⇒ Object
42 43 44 45 |
# File 'lib/mongo-lock/configuration.rb', line 42 def set_collections_keep_default collections collections[:default] = @collections[:default] @collections = collections end |
#to_hash ⇒ Object
51 52 53 54 55 56 57 58 59 60 |
# File 'lib/mongo-lock/configuration.rb', line 51 def to_hash { timeout_in: timeout_in, limit: limit, frequency: frequency, expires_after: expires_after, owner: owner, raise: raise } end |