whoosh 1.7.0 → 1.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7276060a2fd0b8ef3edc620c087767b92de6684e6ef54a130f5c3b45f5468a52
4
- data.tar.gz: 98f9f219bbc2e01af9ba63803a525d100fcd70adf397248065db796b28319ae4
3
+ metadata.gz: 0ff8bb40124a953ebe2ed2524d79fa08961b19aa533efc4430e7f8011f3cfc82
4
+ data.tar.gz: 6dd2e3f3d79fed980cb56352f463fceb0d3f6569556b9f2dc03986d4e1c09d2d
5
5
  SHA512:
6
- metadata.gz: a12f5a8f431ff694382192e046072596beeaced996cf47e19633ea3974ebd7bae17bc079118b28cc08b019282219d0ff4cf263291eed418a38d2f32a4021d38a
7
- data.tar.gz: 76c4e804ea925a037ecd60fcc02834800fb0d2ec000d9fdfb48a7a142625c32e37dd3f8bdbf56bae934f1a6ee46a3731a1f0db06cddac660630c4f14bdccd579
6
+ metadata.gz: e1dc05a5db34f320c44271054c1d1070b2be879018933a6837700fd8a62f60971028f61638e4dac7ed91eba45b21898fe9aa9bbcf35dc42698843e2717f08235
7
+ data.tar.gz: dacb25be02806eff8256280ee0199a01877234646c7229bb1e3d1428b0eb1d895c39ea5599c06ffe6a618d222fc4fb1344c7958876c48f805dd889fd2fb7bd50
data/lib/whoosh/app.rb CHANGED
@@ -622,9 +622,16 @@ module Whoosh
622
622
  # Call handler
623
623
  if handler[:endpoint_class]
624
624
  # Class-based endpoint
625
- endpoint = handler[:endpoint_class].new
626
- context = Endpoint::Context.new(self, request)
627
- result = endpoint.call(context.request)
625
+ endpoint_class = handler[:endpoint_class]
626
+ endpoint = endpoint_class.new
627
+ if endpoint_class.respond_to?(:dependencies)
628
+ endpoint_class.dependencies.each do |dep|
629
+ value = @di.resolve(dep, request: request)
630
+ endpoint.instance_variable_set(:"@#{dep}", value)
631
+ endpoint.define_singleton_method(dep) { instance_variable_get(:"@#{dep}") }
632
+ end
633
+ end
634
+ result = endpoint.call(request)
628
635
  else
629
636
  # Inline block endpoint
630
637
  block = handler[:block]
@@ -35,6 +35,14 @@ module Whoosh
35
35
  @declared_routes
36
36
  end
37
37
 
38
+ def inject(*names)
39
+ @dependencies = names
40
+ end
41
+
42
+ def dependencies
43
+ @dependencies || []
44
+ end
45
+
38
46
  def get(path, **opts)
39
47
  declare_route("GET", path, **opts)
40
48
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Whoosh
4
- VERSION = "1.7.0"
4
+ VERSION = "1.8.0"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: whoosh
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.0
4
+ version: 1.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Johannes Dwi Cahyo