yael 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3d3346dbd1cfffad67500419126e580b8e0d5958ac592081a8f785bbe919f95e
4
- data.tar.gz: 1b4a4ebb714b18aee11456ff0cf0ed6199a95a3936733339a24445aa83cb4f05
3
+ metadata.gz: 07272b866ce348e79efb9e790971130208778deeddda76a0f25b8ef31c12c8f6
4
+ data.tar.gz: 00cce80102e807dd79ce2eee4c89229f2a9b97511d27e0b924bd652cb754ef8f
5
5
  SHA512:
6
- metadata.gz: ee589c82b3c850762431bc2828dd4a084117231abe80b0dd3597d2fd3cbd08f74307242e473f6c3921dd5d523e7981816619ad92d1321f9e4ea56feca586935b
7
- data.tar.gz: dec65e4ec61905fc3e50a696d4f1a40fd2bc0960c03b12489f9cbd4ca1e032a6d4c8b3de1f1d441384e097f3ef61c4b051c78101a86d3a501d2bb5101e1ae830
6
+ metadata.gz: 930c85538376232c96631656b548efb6c7d0bfc382f9e5035eabcf5d963e0d70708a7e35da851e0328acc6014a95d26360493e0c2bf9536c3b68599136605a5f
7
+ data.tar.gz: 62a5196c9402528681213addc7802e13fec28c4ad0c3aae01b53c0083d1303961f6cffc448bb899c8f426c2dc2a6fd6729496fe1a4539c566b8e9633f96e3f13
@@ -4,17 +4,24 @@ module Yael
4
4
  class ExecutionJob < ActiveJob::Base
5
5
  retry_on ActiveRecord::Deadlocked
6
6
 
7
- def perform(target_name, method, args)
7
+ def perform(target_name, method, stream, args)
8
8
  target_constant = target_name.constantize
9
- parameters = extract_parameters(target_constant.method(method), args)
9
+ parameters = extract_parameters(target_constant.method(method), stream, args)
10
10
  target_constant.public_send method, **parameters
11
11
  end
12
12
 
13
13
  private
14
14
 
15
- def extract_parameters(method, args)
15
+ def extract_parameters(method, stream, args)
16
16
  requested = method.parameters.select { |e| e.first == :keyreq }.map(&:second)
17
+ args.merge!(stream: stream) if requested.include?(:stream)
18
+ args.merge!(publisher: publisher_for(stream: stream)) if requested.include?(:publisher)
17
19
  args.slice(*requested)
18
20
  end
21
+
22
+ def publisher_for(stream:)
23
+ table, _, id = stream.partition "_"
24
+ table.classify.constantize.find(id)
25
+ end
19
26
  end
20
27
  end
data/lib/yael/route.rb CHANGED
@@ -9,8 +9,8 @@ module Yael
9
9
  @target = target
10
10
  @queue = queue
11
11
  @delay = delay
12
- @target_name = target.split("#").first.classify
13
- @target_method = target.split("#").second
12
+ @target_name = target.split(".").first.classify
13
+ @target_method = target.split(".").second
14
14
  end
15
15
 
16
16
  def matches?(stream)
@@ -22,7 +22,7 @@ module Yael
22
22
  def dispatch(event)
23
23
  method = target_method || "on_#{event.name}"
24
24
  args = event.payload.symbolize_keys
25
- ExecutionJob.set(queue: queue, wait: delay).perform_later(target_name, method, args)
25
+ ExecutionJob.set(queue: queue, wait: delay).perform_later(target_name, method, event.stream, args)
26
26
  end
27
27
 
28
28
  private
data/lib/yael/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Yael
4
- VERSION = "0.0.2"
4
+ VERSION = "0.0.3"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yael
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jens Ravens
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-02-08 00:00:00.000000000 Z
11
+ date: 2021-10-22 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Yael is Yet Another Event Library based on top of ActiveJob. It helps
14
14
  you dispatching events asynchronously in your code base and react to them just like