Module: Commons::ClassMethods

Included in:
PPSCommons
Defined in:
lib/pps_commons/commons.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.deep_find(key, object = self, found = nil) ⇒ Object

search through a hash’s nested keys for crap



16
17
18
19
20
21
22
23
# File 'lib/pps_commons/commons.rb', line 16

def ClassMethods.deep_find(key, object=self, found=nil)
  if object.respond_to?(:key?) && object.key?(key)
    object[key]
  elsif object.respond_to?(:each)
    object.find { |k,v| found = deep_find(key, v) }
    found
  end
end

Instance Method Details

#unleash_the_fury_levelObject

this tells EventMachine how many threads it can use. There is a lot of Deferrals in this project so it helps to run a higher number. EM defaults to ‘20’, PPS defaults to ‘40’



10
11
12
13
# File 'lib/pps_commons/commons.rb', line 10

def unleash_the_fury_level
  found = ENV['PPS_THREAD_COUNT'].to_i
  found.eql?(0) ? 40 : found.to_i
end