flame 4.17.0 → 4.18.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/flame/controller.rb +18 -9
- data/lib/flame/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ebb50e9412146b4ff8539c37a33078d360bd7414
|
4
|
+
data.tar.gz: 80a08f804d28d61dd8bf6cfcd9681d923b23cb41
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9680f9cd7ddca87d9024211c0c98c20e611061b2a6934c16a364e083f57076a92dbe5e15d14ce97f090450658517bec0fb3b84a8a3800ccc9da5a7532efdbda9
|
7
|
+
data.tar.gz: 50d5041a23247616a53dd3e605def07edef86705c89cda45dc8f988e55d7f439fde677fef0fca088dcd0265f582556a812581863bc9f7920556ae656f280ecbc
|
data/lib/flame/controller.rb
CHANGED
@@ -9,6 +9,8 @@ module Flame
|
|
9
9
|
class Controller
|
10
10
|
extend Forwardable
|
11
11
|
|
12
|
+
FORBIDDEN_ACTIONS = [].freeze
|
13
|
+
|
12
14
|
## Shortcut for not-inherited public methods: actions
|
13
15
|
def self.actions
|
14
16
|
public_instance_methods(false)
|
@@ -121,8 +123,7 @@ module Flame
|
|
121
123
|
## Execute the method of the controller with hooks (may be overloaded)
|
122
124
|
## @param method [Symbol] name of the controller method
|
123
125
|
def execute(method)
|
124
|
-
|
125
|
-
body send(method, *extract_params_for(method).values)
|
126
|
+
body send(method, *extract_params_for(method))
|
126
127
|
end
|
127
128
|
|
128
129
|
## Default method for Internal Server Error, can be inherited
|
@@ -148,12 +149,18 @@ module Flame
|
|
148
149
|
end
|
149
150
|
|
150
151
|
def extract_params_for(action)
|
151
|
-
#
|
152
|
-
method(action).parameters
|
153
|
-
|
154
|
-
|
155
|
-
|
152
|
+
# Take parameters from action method
|
153
|
+
parameters = method(action).parameters
|
154
|
+
# Fill variables with values from params
|
155
|
+
req_values, opt_values = %i[req opt].map! do |type|
|
156
|
+
params.values_at(
|
157
|
+
*parameters.select { |key, _value| key == type }.map!(&:last)
|
158
|
+
)
|
156
159
|
end
|
160
|
+
# Remove nils from the end of optional values
|
161
|
+
opt_values.pop while opt_values.last.nil? && !opt_values.empty?
|
162
|
+
# Concat values
|
163
|
+
req_values + opt_values
|
157
164
|
end
|
158
165
|
|
159
166
|
def add_controller_class(args)
|
@@ -201,8 +208,10 @@ module Flame
|
|
201
208
|
end
|
202
209
|
|
203
210
|
## Module for public instance methods re-defining from superclass
|
204
|
-
## @example Inherit controller with parent actions
|
211
|
+
## @example Inherit controller with parent actions without forbidden
|
212
|
+
## actions by `extend`
|
205
213
|
## class MyController < BaseController
|
214
|
+
## FORBIDDEN_ACTIONS = %[foo bar baz].freeze
|
206
215
|
## extend Flame::Controller::ParentActions
|
207
216
|
## end
|
208
217
|
module ParentActions
|
@@ -215,7 +224,7 @@ module Flame
|
|
215
224
|
end
|
216
225
|
|
217
226
|
def define_parent_actions
|
218
|
-
superclass.actions.each do |public_method|
|
227
|
+
(superclass.actions - self::FORBIDDEN_ACTIONS).each do |public_method|
|
219
228
|
um = superclass.public_instance_method(public_method)
|
220
229
|
define_method public_method, um
|
221
230
|
end
|
data/lib/flame/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: flame
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.
|
4
|
+
version: 4.18.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexander Popov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-06-
|
11
|
+
date: 2017-06-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|