core-handler 0.0.0 → 0.1.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
  SHA256:
3
- metadata.gz: b1cba00f61d0beed241065e9694b3493ff41e40a5e6e059ce00677a3ad1b1ba4
4
- data.tar.gz: 730d4ee6201dadb1f4457d31d3ac2ea2a1b5c365d75e3ab76f1f15e6d4648b8b
3
+ metadata.gz: cc5c64f58d1b31f8b3b69a144566c92be0cf0764623c15e2d4c6d45b6782e3e9
4
+ data.tar.gz: 8a578e1e1580a1df55b081dcb779ea2979faeb358cc13407aa9ac7719a50b297
5
5
  SHA512:
6
- metadata.gz: c55b9af1df99cbae5129e8d51f36d5091e79af8f3b059a156c32d3509a7d1b9cd18453abe6510b21684422c8e14047fceda3b55f5392cc4edea886d89b2d8479
7
- data.tar.gz: 7bb25ff4166af43a520a945e7d64cc1b6208e11fe614da16ba341b03a000470f46c9e06ee6b760867a4f9e071670ba781da4f2b309d26bf443b58a086b870cf3
6
+ metadata.gz: 264b6eec53fca6de813e7c4b054b6ba00f4aab364cc4ebae66df2a1cb47a189027f27f5276f706ec5e699d17ce509786cdb1e578e82f6a88b26530c7f5e1ac5e
7
+ data.tar.gz: ee3dce009b9909eac54e2bed224856b44eb613f7d3385e3e6f5c60ca0728804678c2b909d937031c2252c5e37ae4c8e45d9f48f6f7356a175d4e8d18c47f6dd7
data/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## [v0.1.0](https://github.com/metabahn/corerb/releases/tag/2021-11-03)
2
+
3
+ *released on 2021-11-03*
4
+
5
+ * `fix` [#103](https://github.com/metabahn/corerb/pull/103) Prevent unnecessary recompiles of the handler pipeline ([bryanp](https://github.com/bryanp))
6
+ * `add` [#102](https://github.com/metabahn/corerb/pull/102) Add a finalizer to the handler pipeline ([bryanp](https://github.com/bryanp))
7
+
1
8
  ## [v0.0.0](https://github.com/metabahn/corerb/releases/tag/2021-11-02)
2
9
 
3
10
  *released on 2021-11-02*
@@ -90,17 +90,26 @@ module Core
90
90
  # [public]
91
91
  #
92
92
  def trigger(object, event, ...)
93
- compile.trigger(object, event, ...)
93
+ finalize.trigger(object, event, ...)
94
+ end
95
+
96
+ # [public]
97
+ #
98
+ def finalize
99
+ compile
100
+
101
+ self
94
102
  end
95
103
 
96
104
  private def compile
105
+ return if compiled?
106
+
97
107
  instance_eval(Compiler.compile(self), __FILE__, __LINE__ - 1)
98
108
  @compiled = true
99
- self
100
109
  end
101
110
 
102
111
  private def recompile
103
- singleton_class.remove_method(:trigger)
112
+ remove_compiled_trigger
104
113
  compile
105
114
  end
106
115
 
@@ -108,6 +117,13 @@ module Core
108
117
  @compiled == true
109
118
  end
110
119
 
120
+ private def remove_compiled_trigger
121
+ return unless compiled?
122
+
123
+ singleton_class.remove_method(:trigger)
124
+ @compiled = false
125
+ end
126
+
111
127
  private def call_handler(object, event, handled, *args, **kwargs, &block)
112
128
  if (pipeline = @pipelines[event])
113
129
  pipeline.call(object, *args, event: handled, **kwargs, &block)
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Core
4
4
  module Handler
5
- VERSION = "0.0.0"
5
+ VERSION = "0.1.0"
6
6
 
7
7
  def self.version
8
8
  VERSION
data/lib/is/handler.rb CHANGED
@@ -48,5 +48,15 @@ module Is
48
48
  handlers.handle(*events, global: global, method: method, context: context, &block)
49
49
  end
50
50
  end
51
+
52
+ extends :implementation, prepend: true do
53
+ # [public]
54
+ #
55
+ def finalize
56
+ super if defined?(super)
57
+ handlers.finalize
58
+ self
59
+ end
60
+ end
51
61
  end
52
62
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: core-handler
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.0
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bryan Powell
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-11-02 00:00:00.000000000 Z
11
+ date: 2021-11-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: core-extension