Class: Mongo::Lock::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/mongo-lock/configuration.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(defaults, options) {|_self| ... } ⇒ Configuration

Returns a new instance of Configuration.

Yields:

  • (_self)

Yield Parameters:



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/mongo-lock/configuration.rb', line 13

def initialize defaults, options, &block
  options = defaults.merge(options)
  options[:collections] ||= {}
  if options[:collection]
    options[:collections][:default] = options[:collection]
  end
  options.each_pair do |key,value|
    self.send(:"#{key}=",value)
  end
  yield self if block_given?
end

Instance Attribute Details

#connectionsObject

Returns the value of attribute connections.



5
6
7
# File 'lib/mongo-lock/configuration.rb', line 5

def connections
  @connections
end

#expires_afterObject

Returns the value of attribute expires_after.



9
10
11
# File 'lib/mongo-lock/configuration.rb', line 9

def expires_after
  @expires_after
end

#frequencyObject

Returns the value of attribute frequency.



8
9
10
# File 'lib/mongo-lock/configuration.rb', line 8

def frequency
  @frequency
end

#limitObject

Returns the value of attribute limit.



6
7
8
# File 'lib/mongo-lock/configuration.rb', line 6

def limit
  @limit
end

#ownerObject

Returns the value of attribute owner.



10
11
12
# File 'lib/mongo-lock/configuration.rb', line 10

def owner
  @owner
end

#raiseObject

Returns the value of attribute raise.



11
12
13
# File 'lib/mongo-lock/configuration.rb', line 11

def raise
  @raise
end

#timeout_inObject

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

#collectionsObject



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_hashObject



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