active_object 5.8.11 → 5.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.irbrc +2 -2
- data/.rubocop.yml +2 -1
- data/README.md +8 -1
- data/active_object.gemspec +1 -0
- data/lib/active_object/hash.rb +7 -1
- data/lib/active_object/object.rb +0 -1
- data/lib/active_object/version.rb +1 -1
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 881c56690618f36c3f9a10fe57d8effb72a0d3674c37e59902bb81a71f9b4a17
|
4
|
+
data.tar.gz: 8a93ffd7957d9b8cf7d49e30a34bed2273e5c9206e2eb79b0120df940aa16f5d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 16450952ceb4a3514a5b2c3adfe215aec0c0460ef06c93e73689d9109134af035418c1bcc327698ec7c3909af849e82adeb97cd6cc40de4094cacd9d6ff54ec6
|
7
|
+
data.tar.gz: 57644c5ec814a62ce95d731f8fdd4ca6fb21d241ea4a3dd273bff0b7afb48a4bc57617dd963ff526867bb4e07a8b8c112f3f487e1632763ed996889d07b9d717
|
data/.irbrc
CHANGED
data/.rubocop.yml
CHANGED
data/README.md
CHANGED
@@ -172,7 +172,7 @@ end
|
|
172
172
|
```
|
173
173
|
|
174
174
|
**Fulfill:**
|
175
|
-
`
|
175
|
+
`fulfill` returns an array filled to given size.
|
176
176
|
|
177
177
|
```ruby
|
178
178
|
['1', '2'].fulfill('x', 4) #=> ['1', '2', 'x', 'x']
|
@@ -818,6 +818,13 @@ h.slice!(:a, :b) #=> { c: 3, d: 4 }
|
|
818
818
|
{ 'firstName' => 'foo', 'last Name' => 'test' }.symbolize_and_underscore_keys #=> { first_name: 'foo', last_name: 'test' }
|
819
819
|
```
|
820
820
|
|
821
|
+
**To Object:**
|
822
|
+
`to_o` converts an object to have an object like API.
|
823
|
+
|
824
|
+
```ruby
|
825
|
+
{ foo: { bar: true } }.to_o.foo.bar #=> true
|
826
|
+
```
|
827
|
+
|
821
828
|
**Transform Keys:**
|
822
829
|
`transform_keys` and `transform_keys!` returns a new hash with all keys converted using the block operation.
|
823
830
|
|
data/active_object.gemspec
CHANGED
data/lib/active_object/hash.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'json'
|
4
|
+
|
3
5
|
module ActiveObject
|
4
6
|
module Hash
|
5
7
|
|
@@ -103,7 +105,7 @@ module ActiveObject
|
|
103
105
|
end
|
104
106
|
|
105
107
|
def extract!(*keys)
|
106
|
-
keys.each_with_object({}) { |key, hash| hash[key] = delete(key) if
|
108
|
+
keys.each_with_object({}) { |key, hash| hash[key] = delete(key) if key?(key) }
|
107
109
|
end
|
108
110
|
|
109
111
|
def hmap(&block)
|
@@ -267,6 +269,10 @@ module ActiveObject
|
|
267
269
|
end
|
268
270
|
end
|
269
271
|
|
272
|
+
def to_o
|
273
|
+
JSON.parse(to_json, object_class: OpenStruct)
|
274
|
+
end
|
275
|
+
|
270
276
|
def transform_keys(&block)
|
271
277
|
dup.transform_keys!(&block)
|
272
278
|
end
|
data/lib/active_object/object.rb
CHANGED
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.
|
4
|
+
version: 5.9.0
|
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-04-
|
11
|
+
date: 2019-04-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -108,6 +108,20 @@ dependencies:
|
|
108
108
|
- - ">="
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: rubocop-performance
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
111
125
|
description: Class extensions of commonly used ruby object helpers.
|
112
126
|
email:
|
113
127
|
- j.gomez@drexed.com
|