Class: Kungfuig::Jobber
- Inherits:
-
Object
- Object
- Kungfuig::Jobber
- Defined in:
- lib/kungfuig/jobber.rb
Overview
Generic helper for massive attaching aspects
Class Method Summary collapse
- .bottleneck(method: nil, receiver: nil, result: nil, args: nil, **_) ⇒ Object
-
.bulk(hos) ⇒ Object
‘Test’: ‘*’: ‘YoJob’.
Class Method Details
.bottleneck(method: nil, receiver: nil, result: nil, args: nil, **_) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/kungfuig/jobber.rb', line 26 def bottleneck(method:nil, receiver:nil, result:nil, args:nil, **_) respond_to = ->(m, r) { r.respond_to? m.to_sym } r = case receiver when Hash, Array, String then receiver when respond_to.curry[:to_hash] then receiver.to_hash when respond_to.curry[:to_h] then receiver.to_h else receiver end return unless (receiver_class = receiver.class.ancestors.detect do |c| @hash[c.name] && @hash[c.name][method] end) Kernel.const_get(@hash[receiver_class.name][method]).perform_async(r, method, result, *args) rescue => e Kungfuig.✍(receiver: [ "Fail [#{e.}]", *e.backtrace.unshift("Backtrace:").join("#{$/}⮩ "), "while #{receiver}" ].join($/), method: method, result: result, args: args) end |
.bulk(hos) ⇒ Object
‘Test’:
'*': 'YoJob'
17 18 19 20 21 22 23 24 |
# File 'lib/kungfuig/jobber.rb', line 17 def bulk(hos) @hash = Kungfuig.load_stuff hos Kungfuig::Aspector.bulk( @hash.map do |klazz, hash| [klazz, { after: hash.map { |k, _| [k, 'Kungfuig::Jobber#bottleneck'] }.to_h }] end.to_h ) end |