lev 2.0.1 → 2.0.2
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.
- data/Gemfile.lock +1 -1
- data/lib/lev/handler.rb +12 -3
- data/lib/lev/version.rb +1 -1
- metadata +4 -4
data/Gemfile.lock
CHANGED
data/lib/lev/handler.rb
CHANGED
@@ -2,6 +2,12 @@
|
|
2
2
|
module Lev
|
3
3
|
|
4
4
|
class Paramifier
|
5
|
+
include ActiveAttr::Model
|
6
|
+
include ActiveAttr::Typecasting
|
7
|
+
|
8
|
+
# Hack to provide ActiveAttr's Boolean type concisely
|
9
|
+
def self.boolean; ActiveAttr::Typecasting::Boolean; end
|
10
|
+
|
5
11
|
def as_hash(keys)
|
6
12
|
keys = [keys].flatten.compact
|
7
13
|
Hash[keys.collect { |key| [key, self.send(key)] }]
|
@@ -59,6 +65,9 @@ module Lev
|
|
59
65
|
# end
|
60
66
|
# end
|
61
67
|
#
|
68
|
+
# Note that if you want to use a "Boolean" type, you need to type it with
|
69
|
+
# a lowercase (type: boolean).
|
70
|
+
#
|
62
71
|
# All handler instance methods have the following available to them:
|
63
72
|
# 1) 'params' -- the params from the input
|
64
73
|
# 2) 'caller' -- the user submitting the input
|
@@ -124,15 +133,15 @@ module Lev
|
|
124
133
|
|
125
134
|
if paramify_classes[group].nil?
|
126
135
|
paramify_classes[group] = Class.new(Lev::Paramifier) do
|
127
|
-
include ActiveAttr::Model
|
128
136
|
cattr_accessor :group
|
129
137
|
end
|
130
|
-
paramify_classes[group].class_eval(&block)
|
131
|
-
paramify_classes[group].group = group
|
132
138
|
|
133
139
|
# Attach a name to this dynamic class
|
134
140
|
const_set("#{group.to_s.capitalize}Paramifier",
|
135
141
|
paramify_classes[group])
|
142
|
+
|
143
|
+
paramify_classes[group].class_eval(&block)
|
144
|
+
paramify_classes[group].group = group
|
136
145
|
end
|
137
146
|
|
138
147
|
# Define the "#{group}_params" method to get the paramifier
|
data/lib/lev/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lev
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-10-
|
12
|
+
date: 2013-10-08 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activemodel
|
@@ -246,7 +246,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
246
246
|
version: '0'
|
247
247
|
segments:
|
248
248
|
- 0
|
249
|
-
hash:
|
249
|
+
hash: -3509729886127451718
|
250
250
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
251
251
|
none: false
|
252
252
|
requirements:
|
@@ -255,7 +255,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
255
255
|
version: '0'
|
256
256
|
segments:
|
257
257
|
- 0
|
258
|
-
hash:
|
258
|
+
hash: -3509729886127451718
|
259
259
|
requirements: []
|
260
260
|
rubyforge_project:
|
261
261
|
rubygems_version: 1.8.25
|