lev 2.2.1 → 2.2.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/lev/handler.rb +28 -28
- data/lib/lev/version.rb +1 -1
- metadata +41 -9
- checksums.yaml +0 -15
data/lib/lev/handler.rb
CHANGED
@@ -14,28 +14,28 @@ module Lev
|
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
17
|
-
# Common methods for all handlers. Handlers are extensions of Routines
|
18
|
-
# and are responsible for taking input data from a form or other widget and
|
17
|
+
# Common methods for all handlers. Handlers are extensions of Routines
|
18
|
+
# and are responsible for taking input data from a form or other widget and
|
19
19
|
# doing something with it. See Lev::Routine for more information.
|
20
20
|
#
|
21
21
|
# All handlers must:
|
22
22
|
# 2) call "lev_handler"
|
23
|
-
# 3) implement the 'handle' method which takes no arguments and does the
|
23
|
+
# 3) implement the 'handle' method which takes no arguments and does the
|
24
24
|
# work the handler is charged with
|
25
|
-
# 4) implement the 'authorized?' method which returns true iff the
|
25
|
+
# 4) implement the 'authorized?' method which returns true iff the
|
26
26
|
# caller is authorized to do what the handler is charged with
|
27
27
|
#
|
28
28
|
# Handlers may:
|
29
29
|
# 1) implement the 'setup' method which runs before 'authorized?' and 'handle'.
|
30
|
-
# This method can do anything, and will likely include setting up some
|
30
|
+
# This method can do anything, and will likely include setting up some
|
31
31
|
# instance objects based on the params.
|
32
32
|
# 2) Call the class method "paramify" to declare, cast, and validate parts of
|
33
33
|
# the params hash. The first argument to paramify is the key in params
|
34
34
|
# which points to a hash of params to be paramified. If this first argument
|
35
|
-
# is unspecified (or specified as `:paramify`, a reserved symbol), the entire
|
36
|
-
# params hash will be paramified. The block passed to paramify looks just
|
35
|
+
# is unspecified (or specified as `:paramify`, a reserved symbol), the entire
|
36
|
+
# params hash will be paramified. The block passed to paramify looks just
|
37
37
|
# like the guts of an ActiveAttr model.
|
38
|
-
#
|
38
|
+
#
|
39
39
|
# When the incoming params includes :search => {:type, :terms, :num_results}
|
40
40
|
# the Handler class would look like:
|
41
41
|
#
|
@@ -53,9 +53,9 @@ module Lev
|
|
53
53
|
#
|
54
54
|
# attribute :num_results, type: Integer
|
55
55
|
# validates :num_results, numericality: { only_integer: true,
|
56
|
-
# greater_than_or_equal_to: 0 }
|
56
|
+
# greater_than_or_equal_to: 0 }
|
57
57
|
# end
|
58
|
-
#
|
58
|
+
#
|
59
59
|
# def handle
|
60
60
|
# # By this time, if there were any errors the handler would have
|
61
61
|
# # already populated the errors object and returned.
|
@@ -81,23 +81,23 @@ module Lev
|
|
81
81
|
#
|
82
82
|
# These methods are available iff these data were supplied in the call
|
83
83
|
# to the handler (not all handlers need all of this). However, note that
|
84
|
-
# the Lev::HandleWith module supplies an easy way to call Handlers from
|
84
|
+
# the Lev::HandleWith module supplies an easy way to call Handlers from
|
85
85
|
# controllers -- when this way is used, all of the methods above are available.
|
86
86
|
#
|
87
|
-
# Handler 'handle' methods don't return anything; they just set values in
|
87
|
+
# Handler 'handle' methods don't return anything; they just set values in
|
88
88
|
# the errors and results objects. The documentation for each handler
|
89
89
|
# should explain what the results will be and any nonstandard data required
|
90
90
|
# to be passed in in the options.
|
91
91
|
#
|
92
|
-
# In addition to the class- and instance-level "call" methods provided by
|
92
|
+
# In addition to the class- and instance-level "call" methods provided by
|
93
93
|
# Lev::Routine, Handlers have a class-level "handle" method (an alias of
|
94
94
|
# the class-level "call" method). The convention for handlers is that the
|
95
95
|
# call methods take a hash of options/inputs. The instance-level handle
|
96
96
|
# method doesn't take any arguments since the arguments have been stored
|
97
97
|
# as instance variables by the time the instance-level handle method is called.
|
98
|
-
#
|
98
|
+
#
|
99
99
|
# Example:
|
100
|
-
#
|
100
|
+
#
|
101
101
|
# class MyHandler
|
102
102
|
# lev_handler
|
103
103
|
# protected
|
@@ -119,7 +119,7 @@ module Lev
|
|
119
119
|
end
|
120
120
|
|
121
121
|
module ClassMethods
|
122
|
-
|
122
|
+
|
123
123
|
def handle(options={})
|
124
124
|
call(options)
|
125
125
|
end
|
@@ -140,14 +140,14 @@ module Lev
|
|
140
140
|
end
|
141
141
|
|
142
142
|
# Attach a name to this dynamic class
|
143
|
-
const_set("#{group.to_s.capitalize}Paramifier",
|
143
|
+
const_set("#{group.to_s.capitalize}Paramifier",
|
144
144
|
paramify_classes[group])
|
145
145
|
|
146
146
|
paramify_classes[group].class_eval(&block)
|
147
147
|
paramify_classes[group].group = group
|
148
148
|
end
|
149
149
|
|
150
|
-
# Define the "#{group}_params" method to get the paramifier
|
150
|
+
# Define the "#{group}_params" method to get the paramifier
|
151
151
|
# instance wrapping the params. Choose the subset of params
|
152
152
|
# based on the group, choosing all params if the default group
|
153
153
|
# is used.
|
@@ -155,7 +155,7 @@ module Lev
|
|
155
155
|
define_method method_name.to_sym do
|
156
156
|
if !instance_variable_get(variable_sym)
|
157
157
|
params_subset = group == :paramify ? params : params[group]
|
158
|
-
instance_variable_set(variable_sym,
|
158
|
+
instance_variable_set(variable_sym,
|
159
159
|
self.class.paramify_classes[group].new(params_subset))
|
160
160
|
end
|
161
161
|
instance_variable_get(variable_sym)
|
@@ -187,12 +187,12 @@ module Lev
|
|
187
187
|
attr_accessor :auth_error_details
|
188
188
|
|
189
189
|
# This is a method required by Lev::Routine. It enforces the steps common
|
190
|
-
# to all handlers.
|
190
|
+
# to all handlers.
|
191
191
|
def exec(options)
|
192
|
-
self.params = options
|
193
|
-
self.request = options
|
194
|
-
self.caller = options
|
195
|
-
self.options = options
|
192
|
+
self.params = options[:params]
|
193
|
+
self.request = options[:request]
|
194
|
+
self.caller = options[:caller]
|
195
|
+
self.options = options.except(:params, :request, :caller)
|
196
196
|
|
197
197
|
setup
|
198
198
|
raise Lev.configuration.security_transgression_error, auth_error_details unless authorized?
|
@@ -203,19 +203,19 @@ module Lev
|
|
203
203
|
# Default setup implementation -- a no-op
|
204
204
|
def setup; end
|
205
205
|
|
206
|
-
# Default authorized? implementation. It returns true so that every
|
206
|
+
# Default authorized? implementation. It returns true so that every
|
207
207
|
# handler realization has to make a conscious decision about who is authorized
|
208
|
-
# to call the handler. To help the common error of forgetting to override this
|
208
|
+
# to call the handler. To help the common error of forgetting to override this
|
209
209
|
# method in a handler instance, we provide an error message when this default
|
210
210
|
# implementation is called.
|
211
211
|
def authorized?
|
212
|
-
self.auth_error_details =
|
212
|
+
self.auth_error_details =
|
213
213
|
"Access to handlers is prevented by default. You need to override the " +
|
214
214
|
"'authorized?' in this handler to explicitly grant access."
|
215
215
|
false
|
216
216
|
end
|
217
217
|
|
218
|
-
|
218
|
+
|
219
219
|
|
220
220
|
# Helper method to validate paramified params and to transfer any errors
|
221
221
|
# into the handler.
|
data/lib/lev/version.rb
CHANGED
metadata
CHANGED
@@ -1,18 +1,20 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lev
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.2.
|
4
|
+
version: 2.2.2
|
5
|
+
prerelease:
|
5
6
|
platform: ruby
|
6
7
|
authors:
|
7
8
|
- JP Slavinsky
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
date:
|
12
|
+
date: 2016-06-30 00:00:00.000000000 Z
|
12
13
|
dependencies:
|
13
14
|
- !ruby/object:Gem::Dependency
|
14
15
|
name: activemodel
|
15
16
|
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
16
18
|
requirements:
|
17
19
|
- - ! '>='
|
18
20
|
- !ruby/object:Gem::Version
|
@@ -20,6 +22,7 @@ dependencies:
|
|
20
22
|
type: :runtime
|
21
23
|
prerelease: false
|
22
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
23
26
|
requirements:
|
24
27
|
- - ! '>='
|
25
28
|
- !ruby/object:Gem::Version
|
@@ -27,6 +30,7 @@ dependencies:
|
|
27
30
|
- !ruby/object:Gem::Dependency
|
28
31
|
name: activerecord
|
29
32
|
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
30
34
|
requirements:
|
31
35
|
- - ! '>='
|
32
36
|
- !ruby/object:Gem::Version
|
@@ -34,6 +38,7 @@ dependencies:
|
|
34
38
|
type: :runtime
|
35
39
|
prerelease: false
|
36
40
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
37
42
|
requirements:
|
38
43
|
- - ! '>='
|
39
44
|
- !ruby/object:Gem::Version
|
@@ -41,6 +46,7 @@ dependencies:
|
|
41
46
|
- !ruby/object:Gem::Dependency
|
42
47
|
name: actionpack
|
43
48
|
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
44
50
|
requirements:
|
45
51
|
- - ! '>='
|
46
52
|
- !ruby/object:Gem::Version
|
@@ -48,6 +54,7 @@ dependencies:
|
|
48
54
|
type: :runtime
|
49
55
|
prerelease: false
|
50
56
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
51
58
|
requirements:
|
52
59
|
- - ! '>='
|
53
60
|
- !ruby/object:Gem::Version
|
@@ -55,6 +62,7 @@ dependencies:
|
|
55
62
|
- !ruby/object:Gem::Dependency
|
56
63
|
name: transaction_isolation
|
57
64
|
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
58
66
|
requirements:
|
59
67
|
- - ! '>='
|
60
68
|
- !ruby/object:Gem::Version
|
@@ -62,6 +70,7 @@ dependencies:
|
|
62
70
|
type: :runtime
|
63
71
|
prerelease: false
|
64
72
|
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
65
74
|
requirements:
|
66
75
|
- - ! '>='
|
67
76
|
- !ruby/object:Gem::Version
|
@@ -69,6 +78,7 @@ dependencies:
|
|
69
78
|
- !ruby/object:Gem::Dependency
|
70
79
|
name: transaction_retry
|
71
80
|
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
72
82
|
requirements:
|
73
83
|
- - ! '>='
|
74
84
|
- !ruby/object:Gem::Version
|
@@ -76,6 +86,7 @@ dependencies:
|
|
76
86
|
type: :runtime
|
77
87
|
prerelease: false
|
78
88
|
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
79
90
|
requirements:
|
80
91
|
- - ! '>='
|
81
92
|
- !ruby/object:Gem::Version
|
@@ -83,6 +94,7 @@ dependencies:
|
|
83
94
|
- !ruby/object:Gem::Dependency
|
84
95
|
name: active_attr
|
85
96
|
requirement: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
86
98
|
requirements:
|
87
99
|
- - ! '>='
|
88
100
|
- !ruby/object:Gem::Version
|
@@ -90,6 +102,7 @@ dependencies:
|
|
90
102
|
type: :runtime
|
91
103
|
prerelease: false
|
92
104
|
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
93
106
|
requirements:
|
94
107
|
- - ! '>='
|
95
108
|
- !ruby/object:Gem::Version
|
@@ -97,6 +110,7 @@ dependencies:
|
|
97
110
|
- !ruby/object:Gem::Dependency
|
98
111
|
name: hashie
|
99
112
|
requirement: !ruby/object:Gem::Requirement
|
113
|
+
none: false
|
100
114
|
requirements:
|
101
115
|
- - ! '>='
|
102
116
|
- !ruby/object:Gem::Version
|
@@ -104,6 +118,7 @@ dependencies:
|
|
104
118
|
type: :runtime
|
105
119
|
prerelease: false
|
106
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
none: false
|
107
122
|
requirements:
|
108
123
|
- - ! '>='
|
109
124
|
- !ruby/object:Gem::Version
|
@@ -111,6 +126,7 @@ dependencies:
|
|
111
126
|
- !ruby/object:Gem::Dependency
|
112
127
|
name: bundler
|
113
128
|
requirement: !ruby/object:Gem::Requirement
|
129
|
+
none: false
|
114
130
|
requirements:
|
115
131
|
- - ! '>='
|
116
132
|
- !ruby/object:Gem::Version
|
@@ -118,6 +134,7 @@ dependencies:
|
|
118
134
|
type: :development
|
119
135
|
prerelease: false
|
120
136
|
version_requirements: !ruby/object:Gem::Requirement
|
137
|
+
none: false
|
121
138
|
requirements:
|
122
139
|
- - ! '>='
|
123
140
|
- !ruby/object:Gem::Version
|
@@ -125,6 +142,7 @@ dependencies:
|
|
125
142
|
- !ruby/object:Gem::Dependency
|
126
143
|
name: rake
|
127
144
|
requirement: !ruby/object:Gem::Requirement
|
145
|
+
none: false
|
128
146
|
requirements:
|
129
147
|
- - ! '>='
|
130
148
|
- !ruby/object:Gem::Version
|
@@ -132,6 +150,7 @@ dependencies:
|
|
132
150
|
type: :development
|
133
151
|
prerelease: false
|
134
152
|
version_requirements: !ruby/object:Gem::Requirement
|
153
|
+
none: false
|
135
154
|
requirements:
|
136
155
|
- - ! '>='
|
137
156
|
- !ruby/object:Gem::Version
|
@@ -139,6 +158,7 @@ dependencies:
|
|
139
158
|
- !ruby/object:Gem::Dependency
|
140
159
|
name: rspec
|
141
160
|
requirement: !ruby/object:Gem::Requirement
|
161
|
+
none: false
|
142
162
|
requirements:
|
143
163
|
- - ! '>='
|
144
164
|
- !ruby/object:Gem::Version
|
@@ -146,6 +166,7 @@ dependencies:
|
|
146
166
|
type: :development
|
147
167
|
prerelease: false
|
148
168
|
version_requirements: !ruby/object:Gem::Requirement
|
169
|
+
none: false
|
149
170
|
requirements:
|
150
171
|
- - ! '>='
|
151
172
|
- !ruby/object:Gem::Version
|
@@ -153,6 +174,7 @@ dependencies:
|
|
153
174
|
- !ruby/object:Gem::Dependency
|
154
175
|
name: sqlite3
|
155
176
|
requirement: !ruby/object:Gem::Requirement
|
177
|
+
none: false
|
156
178
|
requirements:
|
157
179
|
- - ! '>='
|
158
180
|
- !ruby/object:Gem::Version
|
@@ -160,6 +182,7 @@ dependencies:
|
|
160
182
|
type: :development
|
161
183
|
prerelease: false
|
162
184
|
version_requirements: !ruby/object:Gem::Requirement
|
185
|
+
none: false
|
163
186
|
requirements:
|
164
187
|
- - ! '>='
|
165
188
|
- !ruby/object:Gem::Version
|
@@ -167,6 +190,7 @@ dependencies:
|
|
167
190
|
- !ruby/object:Gem::Dependency
|
168
191
|
name: debugger
|
169
192
|
requirement: !ruby/object:Gem::Requirement
|
193
|
+
none: false
|
170
194
|
requirements:
|
171
195
|
- - ! '>='
|
172
196
|
- !ruby/object:Gem::Version
|
@@ -174,6 +198,7 @@ dependencies:
|
|
174
198
|
type: :development
|
175
199
|
prerelease: false
|
176
200
|
version_requirements: !ruby/object:Gem::Requirement
|
201
|
+
none: false
|
177
202
|
requirements:
|
178
203
|
- - ! '>='
|
179
204
|
- !ruby/object:Gem::Version
|
@@ -185,10 +210,6 @@ executables: []
|
|
185
210
|
extensions: []
|
186
211
|
extra_rdoc_files: []
|
187
212
|
files:
|
188
|
-
- LICENSE.txt
|
189
|
-
- README.md
|
190
|
-
- Rakefile
|
191
|
-
- lib/lev.rb
|
192
213
|
- lib/lev/better_active_model_errors.rb
|
193
214
|
- lib/lev/delegate_to_routine.rb
|
194
215
|
- lib/lev/error.rb
|
@@ -207,6 +228,10 @@ files:
|
|
207
228
|
- lib/lev/transaction_isolation.rb
|
208
229
|
- lib/lev/utilities.rb
|
209
230
|
- lib/lev/version.rb
|
231
|
+
- lib/lev.rb
|
232
|
+
- LICENSE.txt
|
233
|
+
- Rakefile
|
234
|
+
- README.md
|
210
235
|
- spec/create_sprocket_spec.rb
|
211
236
|
- spec/deep_merge_spec.rb
|
212
237
|
- spec/outputs_spec.rb
|
@@ -223,26 +248,33 @@ files:
|
|
223
248
|
homepage: http://github.com/lml/lev
|
224
249
|
licenses:
|
225
250
|
- MIT
|
226
|
-
metadata: {}
|
227
251
|
post_install_message:
|
228
252
|
rdoc_options: []
|
229
253
|
require_paths:
|
230
254
|
- lib
|
231
255
|
required_ruby_version: !ruby/object:Gem::Requirement
|
256
|
+
none: false
|
232
257
|
requirements:
|
233
258
|
- - ! '>='
|
234
259
|
- !ruby/object:Gem::Version
|
235
260
|
version: '0'
|
261
|
+
segments:
|
262
|
+
- 0
|
263
|
+
hash: 3271005735947250586
|
236
264
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
265
|
+
none: false
|
237
266
|
requirements:
|
238
267
|
- - ! '>='
|
239
268
|
- !ruby/object:Gem::Version
|
240
269
|
version: '0'
|
270
|
+
segments:
|
271
|
+
- 0
|
272
|
+
hash: 3271005735947250586
|
241
273
|
requirements: []
|
242
274
|
rubyforge_project:
|
243
|
-
rubygems_version:
|
275
|
+
rubygems_version: 1.8.23.2
|
244
276
|
signing_key:
|
245
|
-
specification_version:
|
277
|
+
specification_version: 3
|
246
278
|
summary: Ride the rails but don't touch them.
|
247
279
|
test_files:
|
248
280
|
- spec/create_sprocket_spec.rb
|
checksums.yaml
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
---
|
2
|
-
!binary "U0hBMQ==":
|
3
|
-
metadata.gz: !binary |-
|
4
|
-
ZDNmNjBkMTY4YWExNTJlYTE0YjViMjc4NGUyNzIwZTY0N2ExN2NjZg==
|
5
|
-
data.tar.gz: !binary |-
|
6
|
-
NjU2YmVkZGExY2I2MTU5Njk2N2NiOWFkODZhYzc1NmQ3OGY0MDRmNQ==
|
7
|
-
SHA512:
|
8
|
-
metadata.gz: !binary |-
|
9
|
-
ZjFmZjA2ZmZiODUzY2I2MDQ4ZTk3YTU1NDQ2ODQyNGM3MmNlYzFiMjZmNDY3
|
10
|
-
ZDM4MjBhMGU4MjE5Zjg4MjcwY2E3OTcxNTUzZDAyMTMwZWFmZjQ4ZmFiNjgy
|
11
|
-
MjIyYmVlMmE0ZTc4NWUxYTRlMTlkMDRmNDg0YWMzZjJlNmI1YWM=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
YjQ4NzQwZmEwOTczNzAxZjUwYzQ3MGNmMDYxNjhiNGI2NGVjM2I1YWU2ZTE0
|
14
|
-
NGM2MmQ4YzExNjI1MzU5Yjk1Y2Q0YWIzMGIzODE5NDVmMWI3ZjJjODYyNjlk
|
15
|
-
NGZkYjY2ZTAwMTg1NmZhNjgyMzdhYTU2OWNmNjcxODA0MzEwNzk=
|