rudash 2.3.0 → 2.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/rudash/update.rb +18 -0
  3. data/lib/rudash.rb +2 -0
  4. metadata +2 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dbc4c64e0ac4afd88c14987bf0a9bf423e83f4f16a3692cfd36f755d06cd1674
4
- data.tar.gz: 2b95666688193596456700bd89d4336332fc2c26a23c311967b33df62fc5af2c
3
+ metadata.gz: 4c42a0d5f572e904adb836f7e67bf6c91b1a54c675a07382cad99063b25d0983
4
+ data.tar.gz: 2132cab1f1aa7cbbf16b93bc22b3285a4d4cd10afaa2b09444e8a69b5025e3d1
5
5
  SHA512:
6
- metadata.gz: 160db19f317177af4d73f6c32556c5b7bf2cf56c81690f0543cfab3dd69b0d300a35a049d9f78add41202eed75afea0c533e1f5db9fbf6face69f4083ba51a4e
7
- data.tar.gz: 4fddf2dd811af7c28f2aa4d9cca5ae697ce1161dd7b007c1715d14b1b5a18aea6b0f1fbfb5d2e1bc54f5d713134ae851b85eeb1d96918109eabf6678ee7a4fdd
6
+ metadata.gz: b764411b08782911a3efd6c6db5473cd76ed4f9a2a535cd6e159981915049014257441b6290525a7d4a46273b5571ff3afb051b474af837c584af1a862794adc
7
+ data.tar.gz: 3a80b8b21589f6a09b9d40c0d6302be461734d84ea17b64a5fff85269554a4ca1829ec558d05f607ea0edf9e4f6188939be8be2619fe961b3430c11cab7e0a3b
@@ -0,0 +1,18 @@
1
+ require_relative 'identity.rb'
2
+ require_relative 'get.rb'
3
+ require_relative 'set.rb'
4
+ require_relative 'head.rb'
5
+
6
+ module Update
7
+ extend Identity
8
+ extend Get
9
+ extend Set
10
+ extend Head
11
+
12
+ def update(object, path, *rest_args)
13
+ updater = self.head(rest_args) || self.method(:identity)
14
+ current_value = self.get(object, path)
15
+ self.set(object, path, updater.(current_value))
16
+ object
17
+ end
18
+ end
data/lib/rudash.rb CHANGED
@@ -40,6 +40,7 @@ require_relative './rudash/join.rb'
40
40
  require_relative './rudash/initial.rb'
41
41
  require_relative './rudash/set.rb'
42
42
  require_relative './rudash/pick.rb'
43
+ require_relative './rudash/update.rb'
43
44
 
44
45
  class R_
45
46
  extend Map
@@ -84,4 +85,5 @@ class R_
84
85
  extend Initial
85
86
  extend Set
86
87
  extend Pick
88
+ extend Update
87
89
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rudash
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.0
4
+ version: 2.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Islam Attrash
@@ -58,6 +58,7 @@ files:
58
58
  - lib/rudash/some.rb
59
59
  - lib/rudash/tail.rb
60
60
  - lib/rudash/uniq.rb
61
+ - lib/rudash/update.rb
61
62
  - lib/rudash/without.rb
62
63
  - lib/utils/index.rb
63
64
  - lib/utils/nested_path_creator.rb