Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
R
rails_param
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
ikcrm_common
rails_param
Commits
22ac9eaa
Commit
22ac9eaa
authored
Aug 07, 2014
by
slainer68
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Tests, tests, tests, yay
parent
43097161
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
257 additions
and
3 deletions
+257
-3
README.md
+1
-1
lib/rails_param/param.rb
+1
-1
spec/rails_param/param_spec.rb
+255
-1
No files found.
README.md
View file @
22ac9eaa
...
...
@@ -40,7 +40,7 @@ By declaring parameter types, incoming parameters will automatically be transfor
-
`String`
-
`Integer`
-
`Float`
-
`
Boolean
`
_("1/0", "true/false", "t/f", "yes/no", "y/n")_
-
`
:boolean/TrueClass/FalseClass
`
_("1/0", "true/false", "t/f", "yes/no", "y/n")_
-
`Array`
_("1,2,3,4,5")_
-
`Hash`
_(key1:value1,key2:value2)_
-
`Date`
,
`Time`
, &
`DateTime`
...
...
lib/rails_param/param.rb
View file @
22ac9eaa
...
...
@@ -53,7 +53,7 @@ module RailsParam
return
DateTime
.
parse
(
param
)
if
type
==
DateTime
return
Array
(
param
.
split
(
options
[
:delimiter
]
||
","
))
if
type
==
Array
return
Hash
[
param
.
split
(
options
[
:delimiter
]
||
","
).
map
{
|
c
|
c
.
split
(
options
[
:separator
]
||
":"
)}]
if
type
==
Hash
return
(
/(false|f|no|n|0)$/i
===
param
.
to_s
?
false
:
(
/(true|t|yes|y|1)$/i
===
param
.
to_s
?
true
:
nil
))
if
type
==
TrueClass
||
type
==
FalseClass
||
type
==
B
oolean
return
(
/(false|f|no|n|0)$/i
===
param
.
to_s
?
false
:
(
/(true|t|yes|y|1)$/i
===
param
.
to_s
?
true
:
nil
))
if
type
==
TrueClass
||
type
==
FalseClass
||
type
==
:b
oolean
return
nil
rescue
ArgumentError
raise
InvalidParameterError
,
"'
#{
param
}
' is not a valid
#{
type
}
"
...
...
spec/rails_param/param_spec.rb
View file @
22ac9eaa
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment