active_object 5.4.0 → 5.5.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7da58dae739c0d4f1a39ab941b0211fb8e4a0d16b22bd59b3e231543b726eb8e
4
- data.tar.gz: 7b3bb0a0a348bf38ffd40dec93dcd48a7be7d2ff848d64a9a55185fa67d95915
3
+ metadata.gz: 23b7700dd3c7bd5a4061ae502428e076fde80119f753df4e8c5a9833a9e0251a
4
+ data.tar.gz: c91137e38e5ce476f0f7e9cb4121eed00734c109b7050bd9218afa2e08c4655b
5
5
  SHA512:
6
- metadata.gz: b53891d3e608524563ae1f0f7359850371c92a5aba69e8caf1a17be99586ccf219fc9026b267857fba35b535e2adfae56e7102446ed66ecb6f1cc7b4f70df3b9
7
- data.tar.gz: 585e0b4f023616f321260822c7c25599084b31af6db23ea48e535f426fa35ea1d09d1fe7367795668569b0495c0e4476a066128396974bdd79bd0c37979c0e52
6
+ metadata.gz: 9fd8511611f4b031bbd7f02b444ee1a3f2261295c526b201215938f9ec10b70905645494828c8487515fa9b2a64ff91098238308373c4498ac1407a46db112f1
7
+ data.tar.gz: ee4279d6451f918746e8644e454cdb8c79ad5c28a099588e154d5216c4eccd801463ecf5f1d80eef585750b17a51f7ff9712a494faa3665098137fe9c26c2901
data/README.md CHANGED
@@ -74,12 +74,20 @@ end
74
74
  #=> 'sample_key'
75
75
  ```
76
76
 
77
+ **safe_eval:**
78
+ `safe_eval` try to evalute or return it's nil.
79
+
80
+ ```ruby
81
+ '[1,2,3]'.safe_eval #=> [1,2,3]
82
+ '[#1,2,3]'.safe_eval #=> nil
83
+ ```
84
+
77
85
  **try_eval:**
78
86
  `try_eval` try to evalute or return it's self.
79
87
 
80
88
  ```ruby
81
- '[1,2,3]'.try_eval #=> [1,2,3]
82
- '[/1,2,3]'.try_eval #=> '[/1,2,3]'
89
+ '[1,2,3]'.try_eval #=> [1,2,3]
90
+ '[#1,2,3]'.try_eval #=> '[#1,2,3]'
83
91
  ```
84
92
 
85
93
  ## Array
@@ -3,7 +3,16 @@
3
3
  if ActiveObject.configuration.autoload_kernel
4
4
  module Kernel
5
5
 
6
+ SANITIZE_EVAL_REGEX ||= /\[\d*,?\d*,?\d*\]/.freeze
7
+
6
8
  # rubocop:disable Lint/RescueException, Security/Eval
9
+ def safe_eval
10
+ val = SANITIZE_EVAL_REGEX.match(self.to_s).to_s
11
+ return if val.nil?
12
+
13
+ eval(val)
14
+ end
15
+
7
16
  def try_eval
8
17
  eval(self)
9
18
  rescue Exception
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ActiveObject
4
- VERSION ||= '5.4.0'
4
+ VERSION ||= '5.5.0'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_object
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.4.0
4
+ version: 5.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Juan Gomez