active_object 5.8.10 → 5.8.11

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
  SHA256:
3
- metadata.gz: 793a265435e94323c9edf1a85958711c6b68714b56db7716e35f3bd781225183
4
- data.tar.gz: 1acc0c3a73bb3a33b7c219e56d63409471596a40bd7304fd5595b6a59854baae
3
+ metadata.gz: 4048bbff49b6a24c4e9ab029efc0241bb0add2dd5fe584240ab0f07c104ddd94
4
+ data.tar.gz: e9151c19ef67880601f31a3d8dc412c1a7581501a98ec839986dd6ec6862792c
5
5
  SHA512:
6
- metadata.gz: c863c4fd63eeddd709bfde59326b94bb9f57a81df7957ca5c8a1f4ea95e4b27eb8dc7cd3c29a38f9f17c9536d80479b8634e3d33589a25ff8d0c3d0f8760a44b
7
- data.tar.gz: 2140a08d8e9769b0859e1156c699e391cba021ff139fcb8c3a789caf749aa640a9df6465dbc87db1455a84a3c79d49971702cb65498acf65bc10f4244454cf0f
6
+ metadata.gz: fa7a4df71f2e05bea04c77885880944449abea2add7ac9dee549e8de327c3cb57711138a29beee3b1b09e4e246fc0205fe0d28b7f9c3f808c19afe3e3a6c1a73
7
+ data.tar.gz: 9152d040a4ae3ce9124940cc35fe4c682c3353c551c679a5e03992cc3036a74d533a9e7c45f1b079c50c0b509a5d41d45dd30de5abd8ac3d5e7766af8b524f66
data/README.md CHANGED
@@ -1598,6 +1598,14 @@ callr.safe_call #=> raises ArgumentError: wrong number of arguments
1598
1598
  3.safe_send(:+, 2) #=> 5
1599
1599
  ```
1600
1600
 
1601
+ **Safe Try:**
1602
+ `safe_try` similar to the try method but returns self instead of nil.
1603
+
1604
+ ```ruby
1605
+ 'example'.safe_try(:upcase) #=> 'EXAMPLE'
1606
+ 'example'.safe_try(:fake_method) #=> 'example'
1607
+ ```
1608
+
1601
1609
  **Salvage:**
1602
1610
  `salvage` returns a placeholder if object is blank?.
1603
1611
 
@@ -77,6 +77,10 @@ module ActiveObject
77
77
  try_send(*keys) || self
78
78
  end
79
79
 
80
+ def safe_try(*obj, &block)
81
+ try(*obj, &block) || self
82
+ end
83
+
80
84
  def salvage(placeholder = '---')
81
85
  blank? ? placeholder : self
82
86
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ActiveObject
4
- VERSION ||= '5.8.10'
4
+ VERSION ||= '5.8.11'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_object
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.8.10
4
+ version: 5.8.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Juan Gomez
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-01-29 00:00:00.000000000 Z
11
+ date: 2019-04-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -169,7 +169,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
169
169
  - !ruby/object:Gem::Version
170
170
  version: '0'
171
171
  requirements: []
172
- rubygems_version: 3.0.2
172
+ rubygems_version: 3.0.3
173
173
  signing_key:
174
174
  specification_version: 4
175
175
  summary: Gem for commonly used ruby object helpers.