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
86c2ca0a
Commit
86c2ca0a
authored
Oct 23, 2014
by
cole bradley
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
set Big decimal precision for strings
parent
96152d09
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
1 deletions
+3
-1
lib/rails_param/param.rb
+3
-1
No files found.
lib/rails_param/param.rb
View file @
86c2ca0a
...
@@ -56,8 +56,10 @@ module RailsParam
...
@@ -56,8 +56,10 @@ module RailsParam
return
Array
(
param
.
split
(
options
[
:delimiter
]
||
","
))
if
type
==
Array
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
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
==
:boolean
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
==
:boolean
return
BigDecimal
.
new
(
param
.
delete
(
'$,'
).
strip
)
if
type
==
BigDecimal
&&
param
.
is_a?
(
String
)
if
type
==
BigDecimal
param
=
param
.
delete
(
'$,'
).
strip
.
to_f
if
param
.
is_a?
(
String
)
return
BigDecimal
.
new
(
param
,
(
options
[
:precision
]
||
DEFAULT_PRECISION
))
if
type
==
BigDecimal
return
BigDecimal
.
new
(
param
,
(
options
[
:precision
]
||
DEFAULT_PRECISION
))
if
type
==
BigDecimal
end
return
nil
return
nil
rescue
ArgumentError
rescue
ArgumentError
raise
InvalidParameterError
,
"'
#{
param
}
' is not a valid
#{
type
}
"
raise
InvalidParameterError
,
"'
#{
param
}
' is not a valid
#{
type
}
"
...
...
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