active_object 5.8.8 → 5.8.9
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.
- checksums.yaml +4 -4
- data/README.md +8 -6
- data/lib/active_object/object.rb +5 -4
- data/lib/active_object/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 731cfd2c3d3dc9d643246fa34facf69837460c7f3d4a03bc23e340227888e05c
|
4
|
+
data.tar.gz: 203ea4a794ea73ec297fef2c8e6e8cf2515e5785b7b9d7e2652936da52b0c027
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b8eef7bfb289c87f1f9e1ff7e7b30bafb781d05e0ba29ba9d6d5a095c0be0a93b2f3bc9b9e813aafc02a20c8b9c75a76681ef145f62d7b51c9d664f421a5f43f
|
7
|
+
data.tar.gz: 33fe831f6f8210efc17d057f24d5017e860a64201ab26ae0cd7f5212058b4923d165f4484007d134b7a8036d86670d1a340a7ab74148548a3497398846889da8
|
data/README.md
CHANGED
@@ -1566,10 +1566,11 @@ true.falsey? #=> false
|
|
1566
1566
|
`safe_call` execute caller to an object and rescues with self.
|
1567
1567
|
|
1568
1568
|
```ruby
|
1569
|
-
callr = -> { 3 *
|
1569
|
+
callr = ->(x) { 3 * x }
|
1570
1570
|
|
1571
|
-
3.safe_call
|
1572
|
-
callr.safe_call #=> 9
|
1571
|
+
3.safe_call #=> 3
|
1572
|
+
callr.safe_call(3) #=> 9
|
1573
|
+
callr.safe_call #=> raises ArgumentError: wrong number of arguments
|
1573
1574
|
```
|
1574
1575
|
|
1575
1576
|
**Safe Send:**
|
@@ -1671,10 +1672,11 @@ false.truthy? #=> false
|
|
1671
1672
|
`try_call` execute caller to an object and rescues with nil.
|
1672
1673
|
|
1673
1674
|
```ruby
|
1674
|
-
callr = -> { 3 *
|
1675
|
+
callr = ->(x) { 3 * x }
|
1675
1676
|
|
1676
|
-
3.try_call
|
1677
|
-
callr.try_call #=> 9
|
1677
|
+
3.try_call #=> nil
|
1678
|
+
callr.try_call(3) #=> 9
|
1679
|
+
callr.try_call #=> raises ArgumentError: wrong number of arguments
|
1678
1680
|
```
|
1679
1681
|
|
1680
1682
|
**Try Send:**
|
data/lib/active_object/object.rb
CHANGED
@@ -69,8 +69,8 @@ module ActiveObject
|
|
69
69
|
is_a?(Range)
|
70
70
|
end
|
71
71
|
|
72
|
-
def safe_call
|
73
|
-
try_call || self
|
72
|
+
def safe_call(*keys)
|
73
|
+
try_call(*keys) || self
|
74
74
|
end
|
75
75
|
|
76
76
|
def safe_send(*keys)
|
@@ -129,10 +129,11 @@ module ActiveObject
|
|
129
129
|
end
|
130
130
|
end
|
131
131
|
|
132
|
-
def try_call
|
132
|
+
def try_call(*keys)
|
133
133
|
return unless respond_to?(:call)
|
134
134
|
|
135
|
-
|
135
|
+
|
136
|
+
keys.blank? ? call : call(*keys)
|
136
137
|
end
|
137
138
|
|
138
139
|
def try_send(*keys)
|