activemodel 5.1.0.beta1 → 5.1.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c49039ac3278df2457a9a5b854001bd2801ba3ca
|
4
|
+
data.tar.gz: 04527bdc4133fa4d524047ade1afef8ab68c83fc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1c07749aa74321242d26822f59f0019b8a7c3a5b5f328b1a4764ac2f983f91cb908ef4f3762af5cf45d98a0bf13e91949272ac15567075d88bc3b7270b850902
|
7
|
+
data.tar.gz: 2f2cf9cab4be69f903d35131a956db57bd49ca6d020a56a43118aacf87c7a758ca907a22782844e37a1edb60453e233d2f241292e01b3f251ff8644d5fd41f12
|
data/CHANGELOG.md
CHANGED
data/lib/active_model/type.rb
CHANGED
@@ -21,16 +21,8 @@ module ActiveModel
|
|
21
21
|
|
22
22
|
class << self
|
23
23
|
attr_accessor :registry # :nodoc:
|
24
|
-
delegate :add_modifier, to: :registry
|
25
24
|
|
26
|
-
# Add a new type to the registry, allowing it to be
|
27
|
-
# symbol by ActiveRecord::Attributes::ClassMethods#attribute. If your
|
28
|
-
# type is only meant to be used with a specific database adapter, you can
|
29
|
-
# do so by passing +adapter: :postgresql+. If your type has the same
|
30
|
-
# name as a native type for the current adapter, an exception will be
|
31
|
-
# raised unless you specify an +:override+ option. +override: true+ will
|
32
|
-
# cause your type to be used instead of the native type. +override:
|
33
|
-
# false+ will cause the native type to be used over yours if one exists.
|
25
|
+
# Add a new type to the registry, allowing it to be get through ActiveModel::Type#lookup
|
34
26
|
def register(type_name, klass = nil, **options, &block)
|
35
27
|
registry.register(type_name, klass, **options, &block)
|
36
28
|
end
|
@@ -21,8 +21,14 @@ module ActiveModel
|
|
21
21
|
case value
|
22
22
|
when ::Float
|
23
23
|
convert_float_to_big_decimal(value)
|
24
|
-
when ::Numeric
|
24
|
+
when ::Numeric
|
25
25
|
BigDecimal(value, precision || BIGDECIMAL_PRECISION)
|
26
|
+
when ::String
|
27
|
+
begin
|
28
|
+
value.to_d
|
29
|
+
rescue ArgumentError
|
30
|
+
BigDecimal(0)
|
31
|
+
end
|
26
32
|
else
|
27
33
|
if value.respond_to?(:to_d)
|
28
34
|
value.to_d
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activemodel
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.1.0.
|
4
|
+
version: 5.1.0.rc1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Heinemeier Hansson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-03-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - '='
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 5.1.0.
|
19
|
+
version: 5.1.0.rc1
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - '='
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 5.1.0.
|
26
|
+
version: 5.1.0.rc1
|
27
27
|
description: A toolkit for building modeling frameworks like Active Record. Rich support
|
28
28
|
for attributes, callbacks, validations, serialization, internationalization, and
|
29
29
|
testing.
|