ruby-rails-extensions 2.1.0.pre.rc.5 → 2.1.0.pre.rc.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +1 -0
- data/lib/ruby-rails-extensions/extensions/to_d.rb +50 -0
- data/lib/ruby-rails-extensions/version.rb +1 -1
- data/lib/ruby-rails-extensions.rb +3 -0
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1fe8c3beb5105b5b0189421aa1f75c312d51a9501f05e87f026b03637d41e4ff
|
4
|
+
data.tar.gz: 38a2b0f8f3d155bb65a0071e0dce6dba2d937471031e4d445ed365f53bc2a948
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8e3cdc51b2b399f646cb4c40d9b6f03592d1901704f358ee3670340e3beba2a1a7fa0cd6aa333e64faebb6635517a436c88e0ca1d7f5c4f6b9419de534112baf
|
7
|
+
data.tar.gz: 796ecdb4e5e704afee97d94865a55611aae8eec1de7d9caa895ec791cb759bb7a25a80b1ea13ebb43a31a9953c6e731c4fb959a33e2302f33462e6ef8c583d7b
|
data/CHANGELOG.md
CHANGED
@@ -8,6 +8,7 @@ Unreleased Changes
|
|
8
8
|
* `Hash#nmerge` and `Hash#nmerge!`
|
9
9
|
* `Hash#left_deep_merge` and `Hash#left_deep_merge!`
|
10
10
|
* `Hash#invert_with_dups`
|
11
|
+
* `BigDecimal#to_d`, `FalseClass#to_d`, `Float#to_d`, `Integer#to_d`, `NilClass#to_d`, `String#to_d`, `TrueClass#to_d`
|
11
12
|
|
12
13
|
2.0.1 (2024-07-29)
|
13
14
|
------------------
|
@@ -0,0 +1,50 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'forwardable'
|
4
|
+
|
5
|
+
BigDecimal.class_eval do
|
6
|
+
# @return [BigDecimal]
|
7
|
+
def to_d
|
8
|
+
self
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
FalseClass.class_eval do
|
13
|
+
# @return [BigDecimal]
|
14
|
+
def to_d
|
15
|
+
BigDecimal('0')
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
Float.class_eval do
|
20
|
+
extend Forwardable
|
21
|
+
|
22
|
+
def_delegators :to_s, :to_d
|
23
|
+
end
|
24
|
+
|
25
|
+
Integer.class_eval do
|
26
|
+
extend Forwardable
|
27
|
+
|
28
|
+
def_delegators :to_s, :to_d
|
29
|
+
end
|
30
|
+
|
31
|
+
NilClass.class_eval do
|
32
|
+
# @return [BigDecimal]
|
33
|
+
def to_d
|
34
|
+
BigDecimal('0')
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
String.class_eval do
|
39
|
+
# @return [BigDecimal]
|
40
|
+
def to_d
|
41
|
+
BigDecimal(self)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
TrueClass.class_eval do
|
46
|
+
# @return [BigDecimal]
|
47
|
+
def to_d
|
48
|
+
BigDecimal('1')
|
49
|
+
end
|
50
|
+
end
|
@@ -31,8 +31,10 @@ module RubyRailsExtensions
|
|
31
31
|
in_utc
|
32
32
|
input
|
33
33
|
invert_with_dups
|
34
|
+
left_deep_merge
|
34
35
|
month_and_year
|
35
36
|
month_year
|
37
|
+
nmerge
|
36
38
|
no_keys
|
37
39
|
no_values
|
38
40
|
only_some
|
@@ -48,6 +50,7 @@ module RubyRailsExtensions
|
|
48
50
|
select_present_join
|
49
51
|
set_to_sentence
|
50
52
|
to_bool
|
53
|
+
to_d
|
51
54
|
to_dec
|
52
55
|
to_i
|
53
56
|
to_local
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-rails-extensions
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1.0.pre.rc.
|
4
|
+
version: 2.1.0.pre.rc.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brands Insurance
|
@@ -98,6 +98,7 @@ files:
|
|
98
98
|
- lib/ruby-rails-extensions/extensions/select_present_join.rb
|
99
99
|
- lib/ruby-rails-extensions/extensions/set_to_sentence.rb
|
100
100
|
- lib/ruby-rails-extensions/extensions/to_bool.rb
|
101
|
+
- lib/ruby-rails-extensions/extensions/to_d.rb
|
101
102
|
- lib/ruby-rails-extensions/extensions/to_dec.rb
|
102
103
|
- lib/ruby-rails-extensions/extensions/to_i.rb
|
103
104
|
- lib/ruby-rails-extensions/extensions/to_local.rb
|