cpt_hook 0.1.0 → 0.2.0

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
  SHA1:
3
- metadata.gz: 1701e85c384616c631dd22041b978f86d565fb3e
4
- data.tar.gz: a438af75ca96bebd63e8878dfcf0de8eafbc7474
3
+ metadata.gz: 97f08b3f7392783b1b9251d4775c486ce79c99e5
4
+ data.tar.gz: 5d685bcb264b6444e26be5d4881897b2d944a8d7
5
5
  SHA512:
6
- metadata.gz: 0f4980636453eef0c2fd978a0d2c260efb0f1a2a0e3368c0f59f276189ff5b1a41a0f9682b16fd4e3594b25f7396f054b0a19f2a917081bb85e761bea7e51e1f
7
- data.tar.gz: 97c51cfbc2d47811540b21810ca4227e3af3d3382f7ee131d7ee588c39a1b123e27f337645b598cec3914cb37a675bc6d7574b4a95623df7ff939632a6ac6b76
6
+ metadata.gz: 778b3c11d8960046f7d80b0d19b3afd570611eb5578c04e5ab6320a576f784984d3bf0149d5e51fae950e26eaa46d8392e98b240a0a592a6727a9afb2f65380c
7
+ data.tar.gz: da271dbea04cb3afae2665e7f7472b3ef6633cc4b81d33f54aff580652d9ff49f061f80f94416b429330d58d845f48f7425be8fc9f3f0cc033e1b14ce8498c94
@@ -10,7 +10,6 @@ module CptHook
10
10
  super(obj)
11
11
 
12
12
  additional_contexts = [additional_contexts] unless additional_contexts.is_a?(Array)
13
-
14
13
  _add_hooks(:before, method_hooks, additional_contexts)
15
14
  _add_hooks(:after, method_hooks, additional_contexts)
16
15
 
@@ -35,13 +34,15 @@ module CptHook
35
34
  method_hooks.select {|hook| hook.key?(which)}.each do |hook|
36
35
  hook[:contexts] = hook.fetch(:contexts, []).concat(additional_contexts)
37
36
  define_singleton_method("#{which}_#{hook[which]}") do |*args, &block|
38
- hook[:call].each do |hook_fn|
37
+ hook[:call_chain].each do |call_chain|
38
+ call_args = call_chain.fetch(:with, [])
39
+ hook_fn = call_chain[:call]
39
40
  if hook_fn.is_a?(Proc)
40
- hook_fn.call
41
+ hook_fn.call(*call_args)
41
42
  else
42
43
  context = hook[:contexts].unshift(__getobj__).find {|c| c.respond_to?(hook_fn)}
43
44
  raise "No context found for #{which} hook: #{hook_fn}" unless context
44
- context.send(hook_fn)
45
+ context.send(hook_fn, *call_args)
45
46
  end
46
47
  end
47
48
  end
@@ -1,3 +1,3 @@
1
1
  module CptHook
2
- VERSION = '0.1.0'
2
+ VERSION = '0.2.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cpt_hook
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - JDonavan
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-11-26 00:00:00.000000000 Z
11
+ date: 2017-11-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler