leanweb 0.5.2 → 0.5.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: d558c8dc51eb0ded4ae4ca0c73bed085cbc9f807df31f615ec697f2555c59492
4
- data.tar.gz: f45c4c2df3cbdfd6dcc1b56c37e6a79d36b24497b8a62faad2ee2c7d0d47027d
3
+ metadata.gz: f4420d0acf838a96016cabcbdf4fb5977044c4c43c7102bbb7c520dab34a3908
4
+ data.tar.gz: 861d7f89f86f9749ac69e007ffd23218047f6cabf825a53074df2aab953e9bb3
5
5
  SHA512:
6
- metadata.gz: d7e428e0f47aea5c20e8bf59a8bc93e4bfec30488c9e84a2e9d3d26901fcd6ae5b96710fd7cfc4346c028781879cf343bc479069aec58b0e3f41ef1ec43a8a42
7
- data.tar.gz: 87a6f8b615112c8525a9241b6fc0d4b02b305334abc064072b6c4babe80a775af138fa935161211c9af547acbdef9f9ab808aa1f2455f221357b17904fd4a498
6
+ metadata.gz: 3377a07bfdee4a0fe5ebfdd40d3094786ac204b2301eafbf796b296bcce86ab6728352246f74abea581d5910f0f3868d5d11c7706ee4f61ce5275f74914365c4
7
+ data.tar.gz: 616f2bcc6979253f43d20135a72a3537c6eb3680278c39fa73c879e0a088434c1242f10f200202ab0ec5533c746cab0ca971e655ed79956cdd3f3bca6886bac8
data/lib/leanweb/route.rb CHANGED
@@ -72,9 +72,6 @@ module LeanWeb
72
72
  return respond_proc(request) if @action.instance_of?(Proc)
73
73
 
74
74
  respond_method(request)
75
- rescue NoMethodError
76
- controller = default_controller_class.new(self)
77
- controller.default_static_action(guess_view_path)
78
75
  end
79
76
 
80
77
  # String path, independent if {#path} is Regexp or String.
@@ -157,14 +154,28 @@ module LeanWeb
157
154
  Controller
158
155
  end
159
156
 
157
+ def default_static_action
158
+ default_controller_class.new(self).default_static_action(guess_view_path)
159
+ end
160
+
161
+ def controller_for_request(request)
162
+ require_relative("#{CONTROLLER_PATH}/#{@action.controller.to_s.snakeize}")
163
+ Object.const_get(@action.controller).new(self, request)
164
+ rescue LoadError
165
+ nil
166
+ end
167
+
160
168
  # @param request [Rack::Request]
161
169
  # @return [Array] a valid Rack response.
162
170
  def respond_method(request)
163
171
  params = action_params(request.path)
164
- require_relative("#{CONTROLLER_PATH}/#{@action.controller.to_s.snakeize}")
165
- controller = Object.const_get(@action.controller).new(self, request)
166
- return controller.public_send(@action.action, **params) \
167
- if params.instance_of?(Hash)
172
+ controller = controller_for_request(request)
173
+
174
+ return default_static_action unless
175
+ controller&.class&.method_defined?(@action.action)
176
+
177
+ return controller.public_send(@action.action, **params) if
178
+ params.instance_of?(Hash)
168
179
 
169
180
  controller.public_send(@action.action, *params)
170
181
  end
@@ -9,5 +9,5 @@
9
9
 
10
10
 
11
11
  module LeanWeb
12
- VERSION = '0.5.2'
12
+ VERSION = '0.5.3'
13
13
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: leanweb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.2
4
+ version: 0.5.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Felix Freeman
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-05-23 00:00:00.000000000 Z
11
+ date: 2023-06-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack
@@ -222,7 +222,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
222
222
  - !ruby/object:Gem::Version
223
223
  version: '0'
224
224
  requirements: []
225
- rubygems_version: 3.4.7
225
+ rubygems_version: 3.4.10
226
226
  signing_key:
227
227
  specification_version: 4
228
228
  summary: LeanWeb is a minimal hybrid static / dynamic web framework