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, **params) ⇒ Object
-
.bulk(hos) ⇒ Object
‘Test’: ‘*’: ‘YoJob’.
Class Method Details
.bottleneck(method: nil, receiver: nil, result: nil, **params) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/kungfuig/jobber.rb', line 43 def bottleneck(method: nil, receiver: nil, result: nil, **params) 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) destination = Kernel.const_get(@hash[receiver_class.name][method]) destination.send(:prepend, Kungfuig::Worker) unless destination.ancestors.include? Kungfuig::Worker destination.perform_async(receiver: r, method: method, result: result, **params) rescue => e Kungfuig. |
.bulk(hos) ⇒ Object
‘Test’:
'*': 'YoJob'
34 35 36 37 38 39 40 41 |
# File 'lib/kungfuig/jobber.rb', line 34 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 |