active_object 5.8.9 → 5.8.10

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: 731cfd2c3d3dc9d643246fa34facf69837460c7f3d4a03bc23e340227888e05c
4
- data.tar.gz: 203ea4a794ea73ec297fef2c8e6e8cf2515e5785b7b9d7e2652936da52b0c027
3
+ metadata.gz: 793a265435e94323c9edf1a85958711c6b68714b56db7716e35f3bd781225183
4
+ data.tar.gz: 1acc0c3a73bb3a33b7c219e56d63409471596a40bd7304fd5595b6a59854baae
5
5
  SHA512:
6
- metadata.gz: b8eef7bfb289c87f1f9e1ff7e7b30bafb781d05e0ba29ba9d6d5a095c0be0a93b2f3bc9b9e813aafc02a20c8b9c75a76681ef145f62d7b51c9d664f421a5f43f
7
- data.tar.gz: 33fe831f6f8210efc17d057f24d5017e860a64201ab26ae0cd7f5212058b4923d165f4484007d134b7a8036d86670d1a340a7ab74148548a3497398846889da8
6
+ metadata.gz: c863c4fd63eeddd709bfde59326b94bb9f57a81df7957ca5c8a1f4ea95e4b27eb8dc7cd3c29a38f9f17c9536d80479b8634e3d33589a25ff8d0c3d0f8760a44b
7
+ data.tar.gz: 2140a08d8e9769b0859e1156c699e391cba021ff139fcb8c3a789caf749aa640a9df6465dbc87db1455a84a3c79d49971702cb65498acf65bc10f4244454cf0f
data/README.md CHANGED
@@ -291,6 +291,13 @@ end
291
291
  'this is a test'.split(' ').strip #=> ['this', 'is', 'a', 'test']
292
292
  ```
293
293
 
294
+ **Swap:**
295
+ `swap` switches places of two elements.
296
+
297
+ ```ruby
298
+ [1, 2, 3].swap(0, 2) #=> [3, 2, 1]
299
+ ```
300
+
294
301
  **To:**
295
302
  `to` returns the beginning of the array up to position.
296
303
 
@@ -654,6 +661,15 @@ h1.dig(:a, :b, :c) #=> :d
654
661
  { :foo => 'foo', :baz => 'baz', :bar => 'bar' }.except(:baz, :bar) #=> { :foo => 'foo' }
655
662
  ```
656
663
 
664
+ **Extract:**
665
+ `extract!` removes and returns the key/value pairs matching the given keys.
666
+
667
+ ```ruby
668
+ {}.extract!(:foo) #=> {}
669
+ { foo: 'foo', baz: 'baz', bar: 'bar' }.extract!(:foo) #=> { foo: 'foo' }
670
+
671
+ ```
672
+
657
673
  **Hmap:**
658
674
  `hmap` and `hmap!` returns a hash that is transformed in place.
659
675
 
@@ -221,6 +221,11 @@ module ActiveObject
221
221
  replace(strip)
222
222
  end
223
223
 
224
+ def swap(from, to)
225
+ self[from], self[to] = self[to], self[from]
226
+ self
227
+ end
228
+
224
229
  def to(position)
225
230
  position >= 0 ? first(position + 1) : self[0..position]
226
231
  end
@@ -102,6 +102,10 @@ module ActiveObject
102
102
  self
103
103
  end
104
104
 
105
+ def extract!(*keys)
106
+ keys.each_with_object({}) { |key, hash| hash[key] = delete(key) if has_key?(key) }
107
+ end
108
+
105
109
  def hmap(&block)
106
110
  dup.hmap!(&block)
107
111
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ActiveObject
4
- VERSION ||= '5.8.9'
4
+ VERSION ||= '5.8.10'
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.9
4
+ version: 5.8.10
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-23 00:00:00.000000000 Z
11
+ date: 2019-01-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler